lib/git.js
function spawn(exe, args, cwd) {
  const deferred = Q.defer();
  const child = cp.spawn(exe, args, {cwd: cwd || process.cwd()});
  const buffer = [];
  child.stderr.on('data', chunk => {
    buffer.push(chunk.toString());
  });
  child.stdout.on('data', chunk => {
    deferred.notify(chunk);
  });
  child.on('close', code => {
    if (code) {
      const msg = buffer.join('') || `Process failed: ${code}`;
      deferred.reject(new ProcessError(code, msg));
    } else {
      deferred.resolve(code);
    }
  });
  return deferred.promise;
}
function spawn(exe, args, cwd) {
  const deferred = Q.defer();
  const child = cp.spawn(exe, args, {cwd: cwd || process.cwd()});
  const buffer = [];
  child.stderr.on('data', chunk => {
    buffer.push(chunk.toString());
  });
  child.stdout.on('data', chunk => {
    deferred.notify(chunk);
  });
  child.on('close', code => {
    if (code) {
      const msg = buffer.join('') || `Process failed: ${code}`;
      deferred.reject(new ProcessError(code, msg));
    } else {
      deferred.resolve(code);
    }
  });
  return deferred.promise;
}
function spawn ( exe , args , cwd ) { const deferred = Q . defer ( ) ; const child = cp . spawn ( exe , args , { cwd : cwd || process . cwd ( ) } ) ; const buffer = [ ] ; child . stderr . on ( 'data' , chunk => { buffer . push ( chunk . toString ( ) ) ; } ) ; child . stdout . on ( 'data' , chunk => { deferred . notify ( chunk ) ; } ) ; child . on ( 'close' , code => { if ( code ) { const msg = buffer . join ( '' ) || ` ${ code } ` ; deferred . reject ( new ProcessError ( code , msg ) ) ; } else { deferred . resolve ( code ) ; } } ) ; return deferred . promise ; }
Util function for handling spawned processes as promises.
@param {string} exe Executable.
@param {Array.<string>} args Arguments.
@param {string} cwd Working directory.
@return {Promise} A promise.
Util function for handling spawned processes as promises .