'use strict'

import crossSpawn from 'cross-spawn-async'

const parseStdioOption = (value) => {
  let ignoreStdout = false
  let ignoreStderr = false
  if (value === 'ignore') {
    ignoreStdout = true
    ignoreStderr = true
  } else if (Array.isArray(value)) {
    ignoreStdout = (value[1] === 'ignore')
    ignoreStderr = (value[1] === 'ignore')
  }
  return [ignoreStdout, ignoreStderr]
}

export default (cmd, args, options = {}) => new Promise((resolve, reject) => {
  const proc = crossSpawn(cmd, args, options)
  let stdout = null
  let stderr = null
  const [ignoreStdout, ignoreStderr] = parseStdioOption(options.stdio)
  if (!ignoreStdout) {
    stdout = []
    proc.stdout.on('data', (data) => { stdout.push(data) })
  }
  if (!ignoreStderr) {
    stderr = []
    proc.stderr.on('data', (data) => { stderr.push(data) })
  }
  proc.once('close', (code) => {
    if (code !== 0) {
      const err = new Error(`Exited with status ${code}`)
      err.exitStatus = code
      if (!ignoreStderr) {
        err.stderr = Buffer.concat(stderr)
      }
      reject(err)
    } else {
      resolve(ignoreStdout ? null : Buffer.concat(stdout))
    }
  })
})

@@ -51,16 +51,93 @@
 async'%0A%0A
+const shouldIgnore = (value) =%3E (value === 'ignore' %7C%7C value === 'inherit')%0A%0A
 const pa
@@ -166,16 +166,16 @@
 e) =%3E %7B%0A
-
   let ig
@@ -226,34 +226,35 @@
 e%0A  if (
-value === 'ignore'
+shouldIgnore(value)
 ) %7B%0A    
@@ -357,73 +357,71 @@
 t = 
-(value%5B1%5D === 'ignore')%0A    ignoreStderr = (value%5B1%5D === 'ignore'
+shouldIgnore(value%5B1%5D)%0A    ignoreStderr = shouldIgnore(value%5B2%5D
 )%0A  

Support stdio inherit