mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-11 04:39:19 +00:00
rename flags
This commit is contained in:
parent
06f33fa3ff
commit
fd30c1d94c
@ -5,7 +5,7 @@ var EventEmitter = require('events').EventEmitter,
|
|||||||
|
|
||||||
function Command(params) {
|
function Command(params) {
|
||||||
params = params || {};
|
params = params || {};
|
||||||
this.isEmit = params.isEmit;
|
this.emitOut = params.emitOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Command = Command;
|
exports.Command = Command;
|
||||||
@ -13,11 +13,11 @@ exports.Command = Command;
|
|||||||
inherits(Command, EventEmitter);
|
inherits(Command, EventEmitter);
|
||||||
|
|
||||||
Command.prototype.enableEmitter = function() {
|
Command.prototype.enableEmitter = function() {
|
||||||
this.isEmit = true;
|
this.emitOut = true;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
Command.prototype.disableEmitter = function() {
|
Command.prototype.disableEmitter = function() {
|
||||||
this.isEmit = false;
|
this.emitOut = false;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@ inherits(Command, ParentCommand);
|
|||||||
*/
|
*/
|
||||||
Command.prototype.run = function(params, callback) {
|
Command.prototype.run = function(params, callback) {
|
||||||
var self = this,
|
var self = this,
|
||||||
stdout = self.isCollect ? '' : null;
|
stdout = self.collectOut ? '' : null;
|
||||||
if (!params.cmd) return callback(new Error('`cmd` is not set'));
|
if (!params.cmd) return callback(new Error('`cmd` is not set'));
|
||||||
if (!params.args) return callback(new Error('`args` is not set'));
|
if (!params.args) return callback(new Error('`args` is not set'));
|
||||||
callback = utils.once(callback);
|
callback = utils.once(callback);
|
||||||
@ -28,8 +28,8 @@ Command.prototype.run = function(params, callback) {
|
|||||||
params.options.cwd = params.options.cwd || this.cwd;
|
params.options.cwd = params.options.cwd || this.cwd;
|
||||||
var cmd = spawn(params.cmd, params.args, params.options);
|
var cmd = spawn(params.cmd, params.args, params.options);
|
||||||
cmd.stdout.on('data', function(data) {
|
cmd.stdout.on('data', function(data) {
|
||||||
if (self.isEmit) self.emit('stdout', data);
|
if (self.emitOut) self.emit('stdout', data);
|
||||||
if (self.isCollect) stdout += data;
|
if (self.collectOut) stdout += data;
|
||||||
});
|
});
|
||||||
cmd.stderr.on('data', function(data) {
|
cmd.stderr.on('data', function(data) {
|
||||||
callback(new Error('Spawned command outputs to stderr: ' + data));
|
callback(new Error('Spawned command outputs to stderr: ' + data));
|
||||||
|
@ -9,7 +9,7 @@ function Scm(params) {
|
|||||||
if (!this.repository && !this.cwd) throw new Error(
|
if (!this.repository && !this.cwd) throw new Error(
|
||||||
'`repository` or `cwd` must be set'
|
'`repository` or `cwd` must be set'
|
||||||
);
|
);
|
||||||
this.isCollect = true;
|
this.collectOut = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Scm = Scm;
|
exports.Scm = Scm;
|
||||||
|
@ -8,7 +8,7 @@ describe('Shell command', function() {
|
|||||||
var shellCommand;
|
var shellCommand;
|
||||||
it('Should be created without errors', function() {
|
it('Should be created without errors', function() {
|
||||||
shellCommand = new ShellCommand({
|
shellCommand = new ShellCommand({
|
||||||
isEmit: true
|
emitOut: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user