var assert = require('assert')
var child_process = require('child_process')
var ExitError = require('exit-error')

module.exports = function run(cmd, options, cb) {
  if (typeof options === 'function') {
    cb = options
    options = undefined
  }

  var opts = options || {}
  var runner = opts.runner || child_process
  var child = runner.spawn('/bin/sh', ['-c', cmd], options)

  console.log('running:', cmd)

  // TODO: make this output something fancier
  if (child.stdout) child.stdout.pipe(process.stdout)
  if (child.stderr) child.stderr.pipe(process.stderr)

  child.on('close', function(code, signal) {
    cb(ExitError(cmd, code, signal))
  });

  return child
}

@@ -314,16 +314,94 @@
 process%0A
+%0A  if (options.sudo)%0A    cmd = 'sudo ' + cmd%0A%0A  console.log('running:', cmd)%0A%0A
   var ch
@@ -457,40 +457,8 @@
 s)%0A%0A
-  console.log('running:', cmd)%0A%0A
   //

Support global sudo