From 3daf1295710b29315573a7afe29c072c35a0e24e Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 30 Nov 2015 17:43:13 -0800 Subject: 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. --- bin/cmd.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/cmd.js b/bin/cmd.js index c342be3..85958c9 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -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) -- cgit v1.2.3