rename flags

This commit is contained in:
oleg 2014-12-14 23:04:00 +03:00
parent 06f33fa3ff
commit fd30c1d94c
4 changed files with 8 additions and 8 deletions

View File

@ -5,7 +5,7 @@ var EventEmitter = require('events').EventEmitter,
function Command(params) {
params = params || {};
this.isEmit = params.isEmit;
this.emitOut = params.emitOut;
}
exports.Command = Command;
@ -13,11 +13,11 @@ exports.Command = Command;
inherits(Command, EventEmitter);
Command.prototype.enableEmitter = function() {
this.isEmit = true;
this.emitOut = true;
return this;
};
Command.prototype.disableEmitter = function() {
this.isEmit = false;
this.emitOut = false;
return this;
};

View File

@ -20,7 +20,7 @@ inherits(Command, ParentCommand);
*/
Command.prototype.run = function(params, callback) {
var self = this,
stdout = self.isCollect ? '' : null;
stdout = self.collectOut ? '' : 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);
@ -28,8 +28,8 @@ Command.prototype.run = function(params, callback) {
params.options.cwd = params.options.cwd || this.cwd;
var cmd = spawn(params.cmd, params.args, params.options);
cmd.stdout.on('data', function(data) {
if (self.isEmit) self.emit('stdout', data);
if (self.isCollect) stdout += data;
if (self.emitOut) self.emit('stdout', data);
if (self.collectOut) stdout += data;
});
cmd.stderr.on('data', function(data) {
callback(new Error('Spawned command outputs to stderr: ' + data));

View File

@ -9,7 +9,7 @@ function Scm(params) {
if (!this.repository && !this.cwd) throw new Error(
'`repository` or `cwd` must be set'
);
this.isCollect = true;
this.collectOut = true;
}
exports.Scm = Scm;

View File

@ -8,7 +8,7 @@ describe('Shell command', function() {
var shellCommand;
it('Should be created without errors', function() {
shellCommand = new ShellCommand({
isEmit: true
emitOut: true
});
});