Fix #8326, add back --quiet option. (#10399)

* Fix issue #8326, quiet the @babel/cli with --quiet cli option.

* --quiet and --verbose options now conflict with each other.
This commit is contained in:
彭驰 2019-10-30 01:28:52 +08:00 committed by Nicolò Ribaudo
parent 1d1fab4ea2
commit 4e5ac1fd5c
2 changed files with 20 additions and 6 deletions

View File

@ -129,11 +129,13 @@ export default async function({
compiledFiles += await handle(filename); compiledFiles += await handle(filename);
} }
console.log( if (!cliOptions.quiet) {
`Successfully compiled ${compiledFiles} ${ console.log(
compiledFiles !== 1 ? "files" : "file" `Successfully compiled ${compiledFiles} ${
} with Babel.`, compiledFiles !== 1 ? "files" : "file"
); } with Babel.`,
);
}
} }
if (cliOptions.watch) { if (cliOptions.watch) {

View File

@ -144,7 +144,14 @@ commander.option(
"--include-dotfiles", "--include-dotfiles",
"Include dotfiles when compiling and copying non-compilable files", "Include dotfiles when compiling and copying non-compilable files",
); );
commander.option("--verbose", "Log everything"); commander.option(
"--verbose",
"Log everything. This option conflicts with --quiet",
);
commander.option(
"--quiet",
"Don't log anything. This option conflicts with --verbose",
);
commander.option( commander.option(
"--delete-dir-on-start", "--delete-dir-on-start",
"Delete the out directory before compilation", "Delete the out directory before compilation",
@ -207,6 +214,10 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
errors.push("--delete-dir-on-start requires --out-dir"); errors.push("--delete-dir-on-start requires --out-dir");
} }
if (commander.verbose && commander.quiet) {
errors.push("--verbose and --quiet cannot be used together");
}
if ( if (
!commander.outDir && !commander.outDir &&
filenames.length === 0 && filenames.length === 0 &&
@ -282,6 +293,7 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
copyFiles: opts.copyFiles, copyFiles: opts.copyFiles,
includeDotfiles: opts.includeDotfiles, includeDotfiles: opts.includeDotfiles,
verbose: opts.verbose, verbose: opts.verbose,
quiet: opts.quiet,
deleteDirOnStart: opts.deleteDirOnStart, deleteDirOnStart: opts.deleteDirOnStart,
sourceMapTarget: opts.sourceMapTarget, sourceMapTarget: opts.sourceMapTarget,
}, },