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