Add a brief summary to CLI's build output (#7439)
* feat(babel-cli): add a brief summary to build output * address feedback * further adjustments * Use quiet output as default, add --verbose * fix tests * remove verbose alias
This commit is contained in:
committed by
Mateusz Burzyński
parent
3e95830646
commit
cc6e739f15
@@ -6,6 +6,8 @@ import fs from "fs";
|
||||
|
||||
import * as util from "./util";
|
||||
|
||||
let compiledFiles = 0;
|
||||
|
||||
export default function(commander, filenames, opts) {
|
||||
function write(src, relative, base, callback) {
|
||||
if (typeof base === "function") {
|
||||
@@ -48,6 +50,8 @@ export default function(commander, filenames, opts) {
|
||||
outputFileSync(dest, res.code);
|
||||
util.chmod(src, dest);
|
||||
|
||||
compiledFiles += 1;
|
||||
|
||||
util.log(src + " -> " + dest);
|
||||
return callback(null, true);
|
||||
},
|
||||
@@ -125,10 +129,17 @@ export default function(commander, filenames, opts) {
|
||||
const filename = filenames[index];
|
||||
|
||||
handle(filename, function(err) {
|
||||
if (err) throw err;
|
||||
if (err) throw new Error(err);
|
||||
index++;
|
||||
if (index !== filenames.length) {
|
||||
sequentialHandle(filenames, index);
|
||||
} else {
|
||||
util.log(
|
||||
`🎉 Successfully compiled ${compiledFiles} ${
|
||||
compiledFiles > 1 ? "files" : "file"
|
||||
} with Babel.`,
|
||||
true,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ commander.option(
|
||||
"--include-dotfiles",
|
||||
"Include dotfiles when compiling and copying non-compilable files",
|
||||
);
|
||||
commander.option("-q, --quiet", "Don't log anything");
|
||||
commander.option("--verbose", "Log everything");
|
||||
commander.option(
|
||||
"--delete-dir-on-start",
|
||||
"Delete the out directory before compilation",
|
||||
@@ -243,7 +243,7 @@ delete opts.outFile;
|
||||
delete opts.outDir;
|
||||
delete opts.copyFiles;
|
||||
delete opts.includeDotfiles;
|
||||
delete opts.quiet;
|
||||
delete opts.verbose;
|
||||
delete opts.configFile;
|
||||
delete opts.deleteDirOnStart;
|
||||
delete opts.keepFileExtension;
|
||||
|
||||
@@ -46,8 +46,8 @@ export function addSourceMappingUrl(code, loc) {
|
||||
return code + "\n//# sourceMappingURL=" + path.basename(loc);
|
||||
}
|
||||
|
||||
export function log(msg) {
|
||||
if (!commander.quiet) console.log(msg);
|
||||
export function log(msg, force) {
|
||||
if (force === true || commander.verbose) console.log(msg);
|
||||
}
|
||||
|
||||
export function transform(filename, code, opts, callback) {
|
||||
|
||||
Reference in New Issue
Block a user