-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
33 lines (26 loc) · 938 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
var _ = require('lodash');
var gitDescribe = require('./lib/git-describe');
module.exports = {
gitDescribe: function() {
var gitDescribeArgs = [].slice.call(arguments);
return new Promise(function(resolve, reject) {
var userCb = null;
for (var i = Math.min(3, gitDescribeArgs.length) - 1; i >= 0; i--) {
if (_.isFunction(gitDescribeArgs[i])) {
userCb = gitDescribeArgs[i];
gitDescribeArgs[i] = cb;
break;
}
}
if (!userCb)
gitDescribeArgs.push(cb);
function cb(err, result) {
if (err) reject(err); else resolve(result);
if (userCb) userCb(err, result);
}
gitDescribe.apply(this, gitDescribeArgs);
});
},
gitDescribeSync: _.partialRight(gitDescribe, null)
};