lib/gitmech.js
// Internal helper to talk to the git subprocess (spawn)
Internal helper to talk to the git subprocess (spawn)
Internal helper to talk to the git subprocess ( spawn )
function gitSpawn (commands, callback) {
  commands = gitCommands.concat(commands)
  var child = childProcess.spawn(gitMech.gitBin, commands, { cwd: workTree })
  var stdout = []
  var stderr = []
  child.stdout.addListener('data', function (text) {
    stdout[stdout.length] = text
  })
  child.stderr.addListener('data', function (text) {
    stderr[stderr.length] = text
  })
  var exitCode
  child.addListener('exit', function (code) {
    exitCode = code
  })
  child.addListener('close', function () {
    if (exitCode > 0 && stderr.length > 0) {
      var err = new Error(gitMech.gitBin + ' ' + commands.join(' ') + '\n' + join(stderr, 'utf8'))
      if (gitENOENT.test(err.message)) {
        err.errno = process.ENOENT
      }
      callback(err)
      return
    }
    callback(null, join(stdout))
  })
  child.stdin.end()
}
function gitSpawn ( commands , callback ) { commands = gitCommands . concat ( commands ) var child = childProcess . spawn ( gitMech . gitBin , commands , { cwd : workTree } ) var stdout = [ ] var stderr = [ ] child . stdout . addListener ( 'data' , function ( text ) { stdout [ stdout . length ] = text } ) child . stderr . addListener ( 'data' , function ( text ) { stderr [ stderr . length ] = text } ) var exitCode child . addListener ( 'exit' , function ( code ) { exitCode = code } ) child . addListener ( 'close' , function ( ) { if ( exitCode > 0 && stderr . length > 0 ) { var err = new Error ( gitMech . gitBin + ' ' + commands . join ( ' ' ) + '\n' + join ( stderr , 'utf8' ) ) if ( gitENOENT . test ( err . message ) ) { err . errno = process . ENOENT } callback ( err ) return } callback ( null , join ( stdout ) ) } ) child . stdin . end ( ) }
Internal helper to talk to the git subprocess (spawn)
Internal helper to talk to the git subprocess ( spawn )