Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename detection should respect short flags #10763

Merged
merged 3 commits into from Jan 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/babel-node/package.json
Expand Up @@ -20,7 +20,7 @@
],
"dependencies": {
"@babel/register": "^7.7.7",
"commander": "^2.8.1",
"commander": "^4.0.1",
"core-js": "^3.2.1",
"lodash": "^4.17.13",
"node-environment-flags": "^1.0.5",
Expand Down
18 changes: 9 additions & 9 deletions packages/babel-node/src/_babel-node.js
Expand Up @@ -169,15 +169,15 @@ if (program.eval || program.print) {
}

if (arg[0] === "-") {
const camelArg = arg
.slice(2)
.replace(/-(\w)/, (s, c) => c.toUpperCase());
const parsedArg = program[camelArg];
if (
arg === "-r" ||
arg === "--require" ||
(parsedArg && parsedArg !== true)
) {
const parsedOption = program.options.find(option => {
return option.long === arg || option.short === arg;
});
if (parsedOption === undefined) {
return;
}
const optionName = parsedOption.attributeName();
const parsedArg = program[optionName];
if (optionName === "require" || (parsedArg && parsedArg !== true)) {
ignoreNext = true;
}
} else {
Expand Down
@@ -0,0 +1 @@
console.log("foo");
@@ -0,0 +1,4 @@
module.exports = function () {
console.log("Preset was loaded, so --presets was used.");
return {};
};
@@ -0,0 +1,3 @@
{
"args": ["--presets", "./presetFile.js", "index"]
}
@@ -0,0 +1,2 @@
Preset was loaded, so --presets was used.
foo
@@ -0,0 +1 @@
console.log("foo");
@@ -0,0 +1,4 @@
module.exports = function () {
console.log("Preset was loaded, so -b was used.");
return {};
};
3 changes: 3 additions & 0 deletions packages/babel-node/test/fixtures/babel-node/-b/options.json
@@ -0,0 +1,3 @@
{
"args": ["-b", "./presetFile.js", "index"]
}
2 changes: 2 additions & 0 deletions packages/babel-node/test/fixtures/babel-node/-b/stdout.txt
@@ -0,0 +1,2 @@
Preset was loaded, so -b was used.
foo