Handle kebab-case args in babel-node. (#8046)

This commit is contained in:
Logan Smyth 2018-05-25 08:40:52 -07:00 committed by GitHub
parent 90a174e7c4
commit cf8058e5b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 1 deletions

View File

@ -150,7 +150,10 @@ if (program.eval || program.print) {
} }
if (arg[0] === "-") { if (arg[0] === "-") {
const parsedArg = program[arg.slice(2)]; const camelArg = arg
.slice(2)
.replace(/-(\w)/, (s, c) => c.toUpperCase());
const parsedArg = program[camelArg];
if ( if (
arg === "-r" || arg === "-r" ||
arg === "--require" || arg === "--require" ||

View File

@ -0,0 +1,7 @@
module.exports = function (api) {
api.cache.forever();
console.log("Config was loaded, so --config-file was used.");
return {};
};

View File

@ -0,0 +1 @@
console.log("foo");

View File

@ -0,0 +1,3 @@
{
"args": ["--config-file", "./configFile.js", "index"]
}

View File

@ -0,0 +1,2 @@
Config was loaded, so --config-file was used.
foo

View File

@ -0,0 +1,7 @@
{
"env": {
"env-name-test": {
"plugins": ["./logPlugin.js"]
}
}
}

View File

@ -0,0 +1 @@
console.log("foo");

View File

@ -0,0 +1,4 @@
module.exports = function () {
console.log("Plugin was loaded, so --env-name matched.");
return {}
}

View File

@ -0,0 +1,3 @@
{
"args": ["--env-name", "env-name-test", "index"]
}

View File

@ -0,0 +1,2 @@
Plugin was loaded, so --env-name matched.
foo