Support all variations of v8Flags (#3578)

This adds support for specifying v8Flags with dashes. Previously only underscores
were allowed.
Also allows specifying values for v8Flags in the from --flag=value, which was not supported till now.
Also add --inspect support.
This commit is contained in:
Daniel Tschinder 2016-07-18 16:36:03 +02:00 committed by Henry Zhu
parent 3cc38a0063
commit 88eec4b852
5 changed files with 35 additions and 4 deletions

View File

@ -20,9 +20,24 @@ if (argSeparator > -1) {
babelArgs = babelArgs.slice(0, argSeparator);
}
/**
* Replace dashes with underscores in the v8Flag name
* Also ensure that if the arg contains a value (e.g. --arg=true)
* that only the flag is returned.
*/
function getNormalizedV8Flag(arg) {
const matches = arg.match(/--(.+)/);
if (matches) {
return `--${matches[1].replace(/-/g, "_")}`;
}
return arg;
}
getV8Flags(function (err, v8Flags) {
babelArgs.forEach(function(arg) {
let flag = arg.split("=")[0];
const flag = arg.split("=")[0];
switch (flag) {
case "-d":
@ -36,16 +51,16 @@ getV8Flags(function (err, v8Flags) {
break;
case "-gc":
case "--expose-gc":
args.unshift("--expose-gc");
break;
case "--inspect":
case "--nolazy":
args.unshift("--nolazy");
args.unshift(flag);
break;
default:
if (v8Flags.indexOf(arg) >= 0 || arg.indexOf("--trace") === 0) {
if (v8Flags.indexOf(getNormalizedV8Flag(flag)) >= 0 || arg.indexOf("--trace") === 0) {
args.unshift(arg);
} else {
args.push(arg);

View File

@ -0,0 +1,4 @@
{
"args": ["--expose-debug-as=customDebug", "--eval", "console.log(customDebug.Debug.DebugEvent.Break)"],
"stdout": "1"
}

View File

@ -0,0 +1,4 @@
{
"args": ["--expose-gc", "--eval", "console.log(typeof global.gc)"],
"stdout": "function"
}

View File

@ -0,0 +1,4 @@
{
"args": ["--expose_debug_as=customDebug", "--eval", "console.log(customDebug.Debug.DebugEvent.Break)"],
"stdout": "1"
}

View File

@ -0,0 +1,4 @@
{
"args": ["--expose_gc", "--eval", "console.log(typeof global.gc)"],
"stdout": "function"
}