mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-25 17:56:17 +00:00
collect stdout only if flag is set
This commit is contained in:
parent
a47f9e2cdf
commit
06f33fa3ff
@ -20,7 +20,7 @@ inherits(Command, ParentCommand);
|
||||
*/
|
||||
Command.prototype.run = function(params, callback) {
|
||||
var self = this,
|
||||
stdout = '';
|
||||
stdout = self.isCollect ? '' : null;
|
||||
if (!params.cmd) return callback(new Error('`cmd` is not set'));
|
||||
if (!params.args) return callback(new Error('`args` is not set'));
|
||||
callback = utils.once(callback);
|
||||
@ -29,8 +29,7 @@ Command.prototype.run = function(params, callback) {
|
||||
var cmd = spawn(params.cmd, params.args, params.options);
|
||||
cmd.stdout.on('data', function(data) {
|
||||
if (self.isEmit) self.emit('stdout', data);
|
||||
// TODO: join stdout only if flag is set
|
||||
stdout += data;
|
||||
if (self.isCollect) stdout += data;
|
||||
});
|
||||
cmd.stderr.on('data', function(data) {
|
||||
callback(new Error('Spawned command outputs to stderr: ' + data));
|
||||
|
@ -9,6 +9,7 @@ function Scm(params) {
|
||||
if (!this.repository && !this.cwd) throw new Error(
|
||||
'`repository` or `cwd` must be set'
|
||||
);
|
||||
this.isCollect = true;
|
||||
}
|
||||
|
||||
exports.Scm = Scm;
|
||||
|
Loading…
Reference in New Issue
Block a user