bin-v8-flags-filter
Advanced tools
Comparing version 1.1.1 to 1.1.2
45
index.js
@@ -31,6 +31,4 @@ var spawn = require('child_process').spawn; | ||
module.exports = function (cliPath, opts) { | ||
var useShutdownMessage = opts && opts.useShutdownMessage; | ||
var forcedKillDelay = opts && opts.forcedKillDelay || DEFAULT_FORCED_KILL_DELAY; | ||
var args = [cliPath]; | ||
function getChildArgs (cliPath) { | ||
var args = [cliPath]; | ||
@@ -55,2 +53,27 @@ process.argv.slice(2).forEach(function (arg) { | ||
return args; | ||
} | ||
function setupSignalHandler (signal, childProcess, useShutdownMessage, forcedKillDelay) { | ||
function forceKill () { | ||
childProcess.kill('SIGTERM'); | ||
} | ||
function handler () { | ||
if (useShutdownMessage) | ||
childProcess.send('shutdown'); | ||
else | ||
childProcess.kill(signal); | ||
setTimeout(forceKill, forcedKillDelay).unref(); | ||
} | ||
process.on(signal, handler); | ||
} | ||
module.exports = function (cliPath, opts) { | ||
var useShutdownMessage = opts && opts.useShutdownMessage; | ||
var forcedKillDelay = opts && opts.forcedKillDelay || DEFAULT_FORCED_KILL_DELAY; | ||
var args = getChildArgs(cliPath); | ||
var cliProc = spawn(process.execPath, args, { stdio: [process.stdin, process.stdout, process.stderr, useShutdownMessage ? 'ipc' : null] }); | ||
@@ -70,15 +93,5 @@ | ||
process.on('SIGINT', function () { | ||
function forceKill () { | ||
cliProc.kill('SIGTERM'); | ||
} | ||
setupSignalHandler('SIGINT', cliProc, useShutdownMessage, forcedKillDelay); | ||
setupSignalHandler('SIGBREAK', cliProc, useShutdownMessage, forcedKillDelay); | ||
if (useShutdownMessage) | ||
cliProc.send('shutdown'); | ||
else | ||
cliProc.kill('SIGINT'); | ||
setTimeout(forceKill, forcedKillDelay).unref(); | ||
}); | ||
if (useShutdownMessage) { | ||
@@ -85,0 +98,0 @@ process.on('message', function (message) { |
{ | ||
"name": "bin-v8-flags-filter", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Filters out v8 flags for your Node.js CLIs.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11386
160