Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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()
  })
})
 
PREVIOUS NEXT
Tagged: #nodejs #exec #exit #code
ADD COMMENT
Topic
Name
1+6 =