lib/bagofcli.js
function execute(command, fallthrough, collectOutput, cb) {
  var collectedStdOut = '';
  var collectedStdErr = '';

  var _exec = child.exec(command, function (err) {
    var result;
    if (err && fallthrough) {
      // camouflage error to allow other execs to keep running
      result = err;
      err = null;
    }
    cb(err, collectedStdOut, collectedStdErr, result);
  });

  _exec.stdout.on('data', function (data) {
    if (collectOutput) {
      collectedStdOut += data.toString().trim();
    } else {
      process.stdout.write(colors.green(data.toString()));
    }
  });

  _exec.stderr.on('data', function (data) {
    if (collectOutput) {
      collectedStdErr += data.toString().trim();
    } else {
      process.stderr.write(colors.red(data.toString()));
    }
  });
}
function execute(command, fallthrough, collectOutput, cb) {
  var collectedStdOut = '';
  var collectedStdErr = '';

  var _exec = child.exec(command, function (err) {
    var result;
    if (err && fallthrough) {
      // camouflage error to allow other execs to keep running
      result = err;
      err = null;
    }
    cb(err, collectedStdOut, collectedStdErr, result);
  });

  _exec.stdout.on('data', function (data) {
    if (collectOutput) {
      collectedStdOut += data.toString().trim();
    } else {
      process.stdout.write(colors.green(data.toString()));
    }
  });

  _exec.stderr.on('data', function (data) {
    if (collectOutput) {
      collectedStdErr += data.toString().trim();
    } else {
      process.stderr.write(colors.red(data.toString()));
    }
  });
}
function execute ( command , fallthrough , collectOutput , cb ) { var collectedStdOut = '' ; var collectedStdErr = '' ; var _exec = child . exec ( command , function ( err ) { var result ; if ( err && fallthrough ) { // camouflage error to allow other execs to keep running result = err ; err = null ; } cb ( err , collectedStdOut , collectedStdErr , result ) ; } ) ; _exec . stdout . on ( 'data' , function ( data ) { if ( collectOutput ) { collectedStdOut += data . toString ( ) . trim ( ) ; } else { process . stdout . write ( colors . green ( data . toString ( ) ) ) ; } } ) ; _exec . stderr . on ( 'data' , function ( data ) { if ( collectOutput ) { collectedStdErr += data . toString ( ) . trim ( ) ; } else { process . stderr . write ( colors . red ( data . toString ( ) ) ) ; } } ) ; }
not exported 
Execute a one-liner command.

The output emitted on stderr and stdout of the child process will either be written to
process.stdout and process.stderr of this process or collected and passed on to the
given callback, depending on collectOutput.

Fallthrough is handy in situation where there are multiple execs running in sequence/parallel,
and they all have to be executed regardless of success/error on either one of them.

@param {String} command: command to execute
@param {Boolean} fallthrough: allow error to be camouflaged as a non-error
@param {Boolean} collectOutput: pass the output of the child process to the callback instead
of writing it to error to be camouflaged as a non-error
@param {Function} cb: (err, stdOutOuput, stdErrOuput, result) callback
@private
not exported Execute a one - liner command .