bin-v8-flags-filter
Advanced tools
Comparing version 1.1.3 to 1.2.0
13
index.js
@@ -19,3 +19,4 @@ var spawn = require('child_process').spawn; | ||
'--allow-natives-syntax', | ||
'--perf-basic-prof' | ||
'--perf-basic-prof', | ||
'--experimental-repl-await' | ||
]; | ||
@@ -33,3 +34,3 @@ | ||
function getChildArgs (cliPath) { | ||
function getChildArgs (cliPath, ignore) { | ||
var args = [cliPath]; | ||
@@ -40,2 +41,7 @@ | ||
if (ignore.indexOf(flag) > -1) { | ||
args.push(arg); | ||
return; | ||
} | ||
if (FLAGS.indexOf(flag) > -1) { | ||
@@ -79,3 +85,4 @@ args.unshift(arg); | ||
var forcedKillDelay = opts && opts.forcedKillDelay || DEFAULT_FORCED_KILL_DELAY; | ||
var args = getChildArgs(cliPath); | ||
var ignore = opts && opts.ignore || []; | ||
var args = getChildArgs(cliPath, ignore); | ||
@@ -82,0 +89,0 @@ var cliProc = spawn(process.execPath, args, { stdio: [process.stdin, process.stdout, process.stderr, useShutdownMessage ? 'ipc' : null] }); |
{ | ||
"name": "bin-v8-flags-filter", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Filters out v8 flags for your Node.js CLIs.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,3 +25,11 @@ # bin-v8-flags-filter | ||
### API | ||
#### `v8FlagsFilter(path, [options])` | ||
- `path` - path to CLI script. | ||
- `options` - an optional object with the following optional keys: | ||
- `ignore` - an array of v8 flags to ignore, i.e. to _not_ filter-out when spawning a new process. | ||
- `forcedKillDelay` - a number of milliseconds after which to send a kill command to the spawned process, only after an interrupt has already been issued. Defaults to `30000`. | ||
- `useShutdownMessage` - rather than forwarding along interrupt signals to the spawned process, instead forwards a `'shutdown'` message to the spawned process. | ||
## Author | ||
[Ivan Nikulin](https://github.com/inikulin) (ifaaan@gmail.com) |
@@ -6,4 +6,7 @@ var path = require('path'); | ||
var noIPCTest = process.argv.indexOf('--no-ipc-test') > -1; | ||
var ignoreTraceGc = process.argv.indexOf('--ignore-trace-gc') > -1; | ||
filter(path.join(__dirname, './actual-cli.js'), { useShutdownMessage: gracefulShutdown || noIPCTest }); | ||
filter(path.join(__dirname, './actual-cli.js'), { | ||
useShutdownMessage: gracefulShutdown || noIPCTest, | ||
ignore: ignoreTraceGc && ['--trace-gc'] | ||
}); |
@@ -23,2 +23,20 @@ var execFile = require('child_process').execFile; | ||
it('Should use ignore option to not filter some v8 flags', function (done) { | ||
var args = [ | ||
path.join(__dirname, './cli.js'), | ||
'--hey', | ||
'--allow-natives-syntax', | ||
'-t=yo', | ||
'--trace-gc', | ||
'--ignore-trace-gc' | ||
]; | ||
execFile(process.execPath, args, function (err, stdout) { | ||
assert.ok(stdout.indexOf('$$$ARGS:["--hey","-t=yo","--trace-gc","--ignore-trace-gc"]$$$') > -1); | ||
assert.ok(stdout.indexOf('$$$ISSMI:true$$$') > -1); | ||
done(); | ||
}); | ||
}); | ||
it('Should use shutdown message', function (done) { | ||
@@ -25,0 +43,0 @@ var args = [ |
Sorry, the diff of this file is not supported yet
12826
186
35