Nodejs Exec Exit Code

new Promise<void>((resolve, reject) => {
  const child = exec('npm run something')

  if (child.stdout) {
    child.stdout.pipe(process.stdout)
  }

  if (child.stderr) {
    child.stderr.pipe(process.stderr)
  }

  child.on('exit', (code) => {
    if (code !== 0) {
      reject()
      return
    }

    resolve()
  })
})
florinrelea