Babel should not silently remove unknown options after command… (#10698)

* chore: add test case

* chore: bump commander to 4.0.1

* fix: let commander.js throw on unknown options after args
This commit is contained in:
Huáng Jùnliàng
2019-11-12 18:25:24 -05:00
committed by Nicolò Ribaudo
parent ce070ce422
commit 7633f09479
8 changed files with 17 additions and 1 deletions

View File

@@ -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",

View File

@@ -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,

View File

@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@@ -0,0 +1,4 @@
{
"args": ["script.js", "--spruce-maps"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
error: unknown option '--spruce-maps'

View File

@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@@ -0,0 +1,4 @@
{
"args": ["--spruce-maps", "script.js"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
error: unknown option '--spruce-maps'