Skip to content

Commit bcb7171

Browse files
Allow Git tag listing
1 parent e5869fe commit bcb7171

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

lib/tag.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,30 @@ module.exports = function (version, message, opt, cb) {
1010
cb = opt;
1111
opt = {};
1212
}
13+
if (!cb && typeof version === 'function') {
14+
cb = version;
15+
version = '';
16+
message = '';
17+
}
1318
if (!cb || typeof cb !== 'function') cb = function () {};
14-
if (!version) return cb(new Error('Version must be defined'));
15-
if (!message) return cb(new Error('Message must be defined'));
19+
if (!message && version) return cb(new Error('Message must be defined'));
1620
if (!opt) opt = {};
1721
if (!opt.cwd) opt.cwd = process.cwd();
1822
if (!opt.args) opt.args = ' ';
1923

2024
var signedarg = opt.signed ? ' -s ' : ' -a ';
2125

22-
var cmd = 'git tag ' + signedarg + ' -m "' + message + '" ' + opt.args + ' ' + escape([version]);
26+
var cmd = 'git tag';
27+
if (version !== '') {
28+
cmd += ' ' + signedarg + ' -m "' + message + '" ' + opt.args + ' ' + escape([version]);
29+
}
2330
var templ = gutil.template(cmd, {file:message});
2431
return exec(templ, {cwd: opt.cwd}, function(err, stdout, stderr){
2532
if (err) return cb(err);
26-
if (!opt.quiet) gutil.log(stdout, stderr);
27-
cb();
33+
if (!opt.quiet && version !== '') gutil.log(stdout, stderr);
34+
if (version === '') {
35+
stdout = stdout.split('\n');
36+
}
37+
cb(stdout);
2838
});
2939
};

0 commit comments

Comments
 (0)