Skip to content

Commit

Permalink
proxy sub-commands' exit codes and signals (#48)
Browse files Browse the repository at this point in the history
This code mostly comes from `mocha` so credit to them.
  • Loading branch information
TooTallNate authored and leo committed Dec 13, 2016
1 parent fed1f8a commit f962060
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,25 @@ class Args {
this.child.on('error', err => {
throw err
})

this.child.on('exit', (code, signal) => {
process.on('exit', () => {
this.child = null
if (signal) {
process.kill(process.pid, signal)
} else {
process.exit(code)
}
})
})

// proxy SIGINT to child process
process.on('SIGINT', () => {
if (this.child) {
this.child.kill('SIGINT')
this.child.kill('SIGTERM') // if that didn't work, we're probably in an infinite loop, so make it die
}
})
}

checkVersion() {
Expand Down

0 comments on commit f962060

Please sign in to comment.