Require users to pass a filename, or specify --no-babelrc when using CLI with stdin. (#7461)

This commit is contained in:
Logan Smyth 2018-03-03 12:29:11 -08:00 committed by GitHub
parent 785131d8e6
commit 212058148c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 3 deletions

View File

@ -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);

View File

@ -1,3 +1,3 @@
{
"args": ["--config-file", "../.othername_babelrc"]
}
"args": ["--config-file", "../.othername_babelrc", "-f", "file.js"]
}

View File

@ -1,3 +1,3 @@
{
"args": ["--out-file", "script.js"]
"args": ["--out-file", "script.js", "-f", "file.js"]
}

View File

@ -0,0 +1,3 @@
{
"args": ["-f", "file.js"]
}