Skip to content

Commit

Permalink
Babel should not silently remove unknown options after command… (#10698)
Browse files Browse the repository at this point in the history
* chore: add test case

* chore: bump commander to 4.0.1

* fix: let commander.js throw on unknown options after args
  • Loading branch information
JLHwung authored and nicolo-ribaudo committed Nov 12, 2019
1 parent ce070ce commit 7633f09
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-cli/package.json
Expand Up @@ -19,7 +19,7 @@
"compiler"
],
"dependencies": {
"commander": "^2.8.1",
"commander": "^4.0.1",
"convert-source-map": "^1.1.0",
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.0.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-cli/src/babel/options.js
Expand Up @@ -163,6 +163,10 @@ commander.option(

commander.version(pkg.version + " (@babel/core " + version + ")");
commander.usage("[options] <files ...>");
// register an empty action handler so that commander.js can throw on
// unknown options _after_ args
// see https://github.com/tj/commander.js/issues/561#issuecomment-522209408
commander.action(() => {});

export type CmdOptions = {
babelOptions: Object,
Expand Down
@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);
@@ -0,0 +1,4 @@
{
"args": ["script.js", "--spruce-maps"],
"stderrContains": true
}
@@ -0,0 +1 @@
error: unknown option '--spruce-maps'
@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);
@@ -0,0 +1,4 @@
{
"args": ["--spruce-maps", "script.js"],
"stderrContains": true
}
@@ -0,0 +1 @@
error: unknown option '--spruce-maps'

0 comments on commit 7633f09

Please sign in to comment.