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 11a9093..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",