diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-12-01 04:43:13 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-12-01 04:43:13 +0300 |
commit | 3daf1295710b29315573a7afe29c072c35a0e24e (patch) | |
tree | 2a0ce5dc4077f77b1daff5ef56901a30f8ec4f5d /bin | |
parent | 4d653bad785cfec25ad499db05bcd5b345242414 (diff) |
cli: Using Control-C should not print "Unexpected error" message (Fix #497)
Terminating a script with Control-C returns exit code 130 in new
versions of node.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cmd.js | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -19,17 +19,18 @@ process.title = 'WebTorrent' var expectedError = false process.on('exit', function (code) { - if (code !== 0 && !expectedError) { - clivas.line('\n{red:UNEXPECTED ERROR:} If this is a bug in WebTorrent, report it!') - clivas.line('{green:OPEN AN ISSUE:} https://github.com/feross/webtorrent/issues\n') - clivas.line( - 'DEBUG INFO: ' + - 'webtorrent ' + require('../package.json').version + ', ' + - 'node ' + process.version + ', ' + - process.platform + ' ' + process.arch + ', ' + - 'exit ' + code - ) - } + if (code === 0 || expectedError) return // normal exit + if (code === 130) return // intentional exit with Control-C + + clivas.line('\n{red:UNEXPECTED ERROR:} If this is a bug in WebTorrent, report it!') + clivas.line('{green:OPEN AN ISSUE:} https://github.com/feross/webtorrent/issues\n') + clivas.line( + 'DEBUG INFO: ' + + 'webtorrent ' + require('../package.json').version + ', ' + + 'node ' + process.version + ', ' + + process.platform + ' ' + process.arch + ', ' + + 'exit ' + code + ) }) process.on('SIGINT', gracefulExit) |