From 2199957d82c85c368020f9d48dca88477fa237bf Mon Sep 17 00:00:00 2001 From: Michiel Helvensteijn Date: Mon, 6 Nov 2017 17:09:24 +0000 Subject: [PATCH 1/2] This ensures that the bugfix to the gift package is included in bapistrano when installing with yarn, regardless of what gift-wrapper does. Discussion about bug: https://github.com/notatestuser/gift/issues/96 "resolutions" feature in yarn: https://yarnpkg.com/lang/en/docs/selective-version-resolutions --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 11a9093..5406ed8 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,9 @@ "devDependencies": { "kn-release": "^1.0.1" }, + "resolutions": { + "gift": "^0.10.1" + }, "scripts": { "test": "standard", "release": "release" From 44d4835a33dec0ce9d2b85c685afdc9f6de8e40d Mon Sep 17 00:00:00 2001 From: Michiel Helvensteijn Date: Mon, 6 Nov 2017 17:32:49 +0000 Subject: [PATCH 2/2] Directly depending on 'gift' library, rather than 'gift-wrapper' --- lib/gitMeta.js | 5 +++-- lib/promisify.js | 10 ++++++++++ package.json | 5 +---- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 lib/promisify.js diff --git a/lib/gitMeta.js b/lib/gitMeta.js index 9355b76..1d9de8a 100644 --- a/lib/gitMeta.js +++ b/lib/gitMeta.js @@ -3,6 +3,7 @@ var path = require('path') var gift = require('gift-wrapper') var co = require('creed').coroutine var log = require('./log') +var promisify = require('./promisify') var gitRoot = findGitRoot() @@ -19,10 +20,10 @@ module.exports = co(function * (asBranch) { if (asBranch) { branch = asBranch } else { - branch = (yield repo.branch()).name + branch = (yield promisify(repo, 'branch')()).name } - var commit = (yield repo.current_commit()).id + var commit = (yield promisify(repo, 'current_commit')()).id return { branch, commit } }) diff --git a/lib/promisify.js b/lib/promisify.js new file mode 100644 index 0000000..c075e4d --- /dev/null +++ b/lib/promisify.js @@ -0,0 +1,10 @@ +module.exports = function promisify (obj, method) { + return function () { + return new Promise((resolve, reject) => { + obj[method]((err, val) => { + if (err) return reject(err) + resolve(val) + }) + }) + } +} diff --git a/package.json b/package.json index 5406ed8..eecd394 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "cli-color": "^1.1.0", "commander": "^2.9.0", "creed": "^1.0.1", - "gift-wrapper": "^1.1.1", + "gift": "^0.10.1", "klaw": "^1.2.0", "lodash": "^4.15.0", "mime": "^1.3.4", @@ -22,9 +22,6 @@ "devDependencies": { "kn-release": "^1.0.1" }, - "resolutions": { - "gift": "^0.10.1" - }, "scripts": { "test": "standard", "release": "release"