diff --git a/app.js b/app.js index 8670da8..306e949 100755 --- a/app.js +++ b/app.js @@ -287,7 +287,7 @@ var ontorrent = function (torrent) { }) vlc.on('exit', function () { - if (!argv.n && argv.quit !== false) process.exit(0) + if (!argv.n && argv.quit !== false) onexit() }) } } @@ -296,28 +296,28 @@ var ontorrent = function (torrent) { player = 'omx' var omx = proc.exec(OMX_EXEC + ' ' + localHref) omx.on('exit', function () { - if (!argv.n && argv.quit !== false) process.exit(0) + if (!argv.n && argv.quit !== false) onexit() }) } if (argv.mplayer) { player = 'mplayer' var mplayer = proc.exec(MPLAYER_EXEC + ' ' + localHref) mplayer.on('exit', function () { - if (!argv.n && argv.quit !== false) process.exit(0) + if (!argv.n && argv.quit !== false) onexit() }) } if (argv.smplayer) { player = 'smplayer' var smplayer = proc.exec(SMPLAYER_EXEC + ' ' + localHref) smplayer.on('exit', function () { - if (!argv.n && argv.quit !== false) process.exit(0) + if (!argv.n && argv.quit !== false) onexit() }) } if (argv.mpv) { player = 'mpv' var mpv = proc.exec(MPV_EXEC + ' ' + localHref) mpv.on('exit', function () { - if (!argv.n && argv.quit !== false) process.exit(0) + if (!argv.n && argv.quit !== false) onexit() }) } if (argv.webplay) { @@ -468,26 +468,16 @@ var ontorrent = function (torrent) { // better output a status message so the user knows we're working on it :) clivas.line('') clivas.line('{yellow:info} {green:peerflix is exiting...}') + if (argv.remove) { + engine.remove(() => process.exit()) + } else { + process.exit() + } } watchVerifying(engine) - if (argv.remove) { - var remove = function () { - onexit() - engine.remove(function () { - process.exit() - }) - } - - process.on('SIGINT', remove) - process.on('SIGTERM', remove) - } else { - process.on('SIGINT', function () { - onexit() - process.exit() - }) - } + process.on('SIGINT' || 'SIGTERM', onexit) } parsetorrent.remote(filename, function (err, parsedtorrent) {