Skip to content

Commit 8b6f21e

Browse files
committed
Throw proper exit code and allow override
1 parent d55e7ef commit 8b6f21e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ function handle(signal, fn) {
3030
exitPromise = exitPromise.then(() => Promise.all(fns.map(fn =>
3131
Promise.resolve(fn.apply(fn, arguments))
3232
)))
33-
.then(prexit.ondone, prexit.ondone)
33+
.catch(() => prexit.code = prexit.code || 1)
34+
.then(prexit.ondone)
3435
})
3536
}
3637

38+
prexit.code = 0
3739
prexit.logExceptions = true
38-
prexit.ondone = () => process.exit() // eslint-disable-line
39-
prexit.signals = ['exit', 'uncaughtException', 'SIGTSTP', 'SIGQUIT', 'SIGHUP', 'SIGTERM', 'SIGINT']
40+
prexit.ondone = () => process.exit(prexit.code) // eslint-disable-line
4041
prexit.signals = ['beforeExit', 'uncaughtException', 'SIGTSTP', 'SIGQUIT', 'SIGHUP', 'SIGTERM', 'SIGINT']

0 commit comments

Comments
 (0)