var _ = require('lodash')
var async = require('async')
var exec = require('child_process').exec
var gutil = require('gulp-util')
var path = require('path')
var through = require('through2')

var PLUGIN_NAME = 'gulp-shell'

function shell(commands, options) {
  if (typeof commands === 'string') {
    commands = [commands]
  }

  if (!Array.isArray(commands)) {
    throw new gutil.PluginError(PLUGIN_NAME, 'Missing commands')
  }

  options = _.extend({
    ignoreErrors: false,
    quiet: false,
    cwd: process.cwd(),
    maxBuffer: 16 * 1024 * 1024
  }, options)

  var pathToBin = path.join(process.cwd(), 'node_modules/.bin')
  var PATH = pathToBin + path.delimiter + process.env.PATH
  var env = _.defaults({PATH: PATH}, process.env)

  var stream = through.obj(function (file, unused, done) {
    var self = this

    async.eachSeries(commands, function (command, done) {
      var context = _.extend({file: file}, options.templateData)
      command = gutil.template(command, context)

      var child = exec(command, {
        env: env,
        cwd: options.cwd,
        maxBuffer: options.maxBuffer
      }, function (error) {
        process.stdin.unpipe(child.stdin)
        process.stdin.pause()

        done(options.ignoreErrors ? null : error)
      })

      process.stdin.resume()
      process.stdin.pipe(child.stdin)

      if (!options.quiet) {
        child.stdout.pipe(process.stdout)
        child.stderr.pipe(process.stderr)
      }
    }, function (error) {
      if (error) {
        self.emit('error', new gutil.PluginError(PLUGIN_NAME, error))
      } else {
        self.push(file)
      }
      done()
    })
  })

  stream.resume()

  return stream
}

shell.task = function (commands, options) {
  return function () {
    var stream = shell(commands, options)

    stream.write(new gutil.File())
    stream.end()

    return stream
  }
}

module.exports = shell

@@ -1120,32 +1120,48 @@
  function (error
+, stdout, stderr
 ) %7B%0A        proc
@@ -1217,24 +1217,145 @@
 in.pause()%0A%0A
+        if (error && !options.ignoreErrors) %7B%0A          error.stdout = stdout%0A          error.stderr = stderr%0A        %7D%0A%0A
         done
@@ -1702,16 +1702,92 @@
 E, error
+, %7B%0A          stdout: error.stdout,%0A          stderr: error.stderr%0A        %7D
 ))%0A     

Add stdout and stderr to the error message