Require users to pass a filename, or specify --no-babelrc when using CLI with stdin. (#7461)
This commit is contained in:
parent
785131d8e6
commit
212058148c
@ -221,6 +221,17 @@ if (commander.deleteDirOnStart && !commander.outDir) {
|
||||
errors.push("--delete-dir-on-start requires --out-dir");
|
||||
}
|
||||
|
||||
if (
|
||||
!commander.outDir &&
|
||||
filenames.length === 0 &&
|
||||
typeof commander.filename !== "string" &&
|
||||
commander.babelrc !== false
|
||||
) {
|
||||
errors.push(
|
||||
"stdin compilation requires either -f/--filename [filename] or --no-babelrc",
|
||||
);
|
||||
}
|
||||
|
||||
if (errors.length) {
|
||||
console.error(errors.join(". "));
|
||||
process.exit(2);
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["--config-file", "../.othername_babelrc"]
|
||||
"args": ["--config-file", "../.othername_babelrc", "-f", "file.js"]
|
||||
}
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["--out-file", "script.js"]
|
||||
"args": ["--out-file", "script.js", "-f", "file.js"]
|
||||
}
|
||||
|
||||
3
packages/babel-cli/test/fixtures/babel/stdin/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/stdin/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["-f", "file.js"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user