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:
parent
3cc38a0063
commit
88eec4b852
@ -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);
|
||||
|
||||
4
packages/babel-cli/test/fixtures/babel-node/v8Flag-dashed-with-param/options.json
vendored
Normal file
4
packages/babel-cli/test/fixtures/babel-node/v8Flag-dashed-with-param/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"args": ["--expose-debug-as=customDebug", "--eval", "console.log(customDebug.Debug.DebugEvent.Break)"],
|
||||
"stdout": "1"
|
||||
}
|
||||
4
packages/babel-cli/test/fixtures/babel-node/v8Flag-dashed/options.json
vendored
Normal file
4
packages/babel-cli/test/fixtures/babel-node/v8Flag-dashed/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"args": ["--expose-gc", "--eval", "console.log(typeof global.gc)"],
|
||||
"stdout": "function"
|
||||
}
|
||||
4
packages/babel-cli/test/fixtures/babel-node/v8Flag-underscored-with-param/options.json
vendored
Normal file
4
packages/babel-cli/test/fixtures/babel-node/v8Flag-underscored-with-param/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"args": ["--expose_debug_as=customDebug", "--eval", "console.log(customDebug.Debug.DebugEvent.Break)"],
|
||||
"stdout": "1"
|
||||
}
|
||||
4
packages/babel-cli/test/fixtures/babel-node/v8Flag-underscored/options.json
vendored
Normal file
4
packages/babel-cli/test/fixtures/babel-node/v8Flag-underscored/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"args": ["--expose_gc", "--eval", "console.log(typeof global.gc)"],
|
||||
"stdout": "function"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user