gulp-hg
Version:
Gulp plugin for Mercurial
39 lines (33 loc) • 958 B
JavaScript
const gutil = require('gulp-util');
const exec = require('child_process').exec;
module.exports = function(opt, cb) {
opt = opt || {};
if (!cb && typeof opt === 'function') {
// No options set
cb = opt;
opt = {};
}
if (typeof cb !== 'function') {
cb = function() {};
}
if (typeof opt === 'object') {
if (!opt.cwd) {
opt.cwd = process.cwd();
}
// Default buffer value for child_process.exec
if (!opt.maxBuffer) {
opt.maxBuffer = 200 * 1024;
}
opt.args = !opt.args ? '' : ' ' + opt.args;
}
var cmd = 'hg log' + opt.args;
return exec(cmd, {cwd: opt.cwd, maxBuffer: opt.maxBuffer}, function(err, stdout, stderr) {
if (err) {
gutil.log(cmd + '\n' + err);
return cb(err, stderr);
}
gutil.log(cmd + '\n' + stdout, stderr);
cb(err, stdout);
});
};
;