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:
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) {
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
"--out-dir", "lib",
|
||||
"--copy-files",
|
||||
"--include-dotfiles",
|
||||
"--ignore", "src/foo"
|
||||
"--ignore", "src/foo",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/index.js -> lib/index.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
"--out-dir", "lib",
|
||||
"--copy-files",
|
||||
"--include-dotfiles",
|
||||
"--only", "src/foo"
|
||||
"--only", "src/foo",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
src/foo/.foo.js -> lib/foo/.foo.js
|
||||
src/foo/bar.js -> lib/foo/bar.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--copy-files", "--include-dotfiles"]
|
||||
"args": ["src", "--out-dir", "lib", "--copy-files", "--include-dotfiles", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
src/.foo.js -> lib/.foo.js
|
||||
src/bar/index.js -> lib/bar/index.js
|
||||
src/foo/foo.js -> lib/foo/foo.js
|
||||
🎉 Successfully compiled 3 files with Babel.
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
"src",
|
||||
"--out-dir", "lib",
|
||||
"--copy-files",
|
||||
"--ignore", "src/foo/*"
|
||||
"--ignore", "src/foo/*",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/index.js -> lib/index.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
"src",
|
||||
"--out-dir", "lib",
|
||||
"--copy-files",
|
||||
"--only", "src/foo/*"
|
||||
"--only", "src/foo/*",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/foo/bar.js -> lib/foo/bar.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--copy-files"]
|
||||
"args": ["src", "--out-dir", "lib", "--copy-files", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
src/bar/index.js -> lib/bar/index.js
|
||||
src/foo/foo.js -> lib/foo/foo.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--ignore", "src/bar"]
|
||||
"args": ["src", "--out-dir", "lib", "--ignore", "src/bar", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/foobar/foo.js -> lib/foobar/foo.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--ignore", "**/*.foo.js"]
|
||||
"args": ["src", "--out-dir", "lib", "--ignore", "**/*.foo.js", "--verbose"]
|
||||
}
|
||||
|
||||
@ -2,3 +2,4 @@ src/a.js -> lib/a.js
|
||||
src/b.js -> lib/b.js
|
||||
src/baz/c.js -> lib/baz/c.js
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 4 files with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--ignore", "src/foo/*"]
|
||||
"args": ["src", "--out-dir", "lib", "--ignore", "src/foo/*", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/bar/index.js -> lib/bar/index.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--only", "**/*.foo.js"]
|
||||
"args": ["src", "--out-dir", "lib", "--only", "**/*.foo.js", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
src/a.foo.js -> lib/a.foo.js
|
||||
src/baz/b.foo.js -> lib/baz/b.foo.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--only", "src/bar/*"]
|
||||
"args": ["src", "--out-dir", "lib", "--only", "src/bar/*", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/bar/index.js -> lib/bar/index.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--copy-files"]
|
||||
"args": ["src", "--out-dir", "lib", "--copy-files", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--keep-file-extension"]
|
||||
"args": ["src", "--out-dir", "lib", "--keep-file-extension", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
src/bar.mjs -> lib/bar.mjs
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["**/src", "--out-dir", "../lib", "--relative"]
|
||||
"args": ["**/src", "--out-dir", "../lib", "--relative", "--verbose"]
|
||||
}
|
||||
|
||||
@ -2,3 +2,4 @@ package1/src/bar/bar1.js -> package1/lib/bar/bar1.js
|
||||
package1/src/foo1.js -> package1/lib/foo1.js
|
||||
package2/src/bar/bar2.js -> package2/lib/bar/bar2.js
|
||||
package2/src/foo2.js -> package2/lib/foo2.js
|
||||
🎉 Successfully compiled 4 files with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--source-maps", "inline", "--out-dir", "lib"]
|
||||
"args": ["src", "--source-maps", "inline", "--out-dir", "lib", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
src/bar/bar.js -> lib/bar/bar.js
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--source-maps", "--out-dir", "lib"]
|
||||
"args": ["src", "--source-maps", "--out-dir", "lib", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
src/bar/bar.js -> lib/bar/bar.js
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/in-files/src/bar/bar.js
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/in-files/src/bar/bar.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
|
||||
}
|
||||
1
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/in-files/src/foo.js
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/in-files/src/foo.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
arr.map(x => x * MULTIPLIER);
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--verbose"]
|
||||
}
|
||||
9
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/out-files/lib/bar/bar.js
vendored
Normal file
9
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/out-files/lib/bar/bar.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
};
|
||||
5
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/out-files/lib/foo.js
vendored
Normal file
5
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/out-files/lib/foo.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/stdout.txt
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --verbose/stdout.txt
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
src/bar/bar.js -> lib/bar/bar.js
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
@ -1,2 +1 @@
|
||||
src/bar/bar.js -> lib/bar/bar.js
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src/foo.js", "--out-dir", "../lib", "--relative"]
|
||||
"args": ["src/foo.js", "--out-dir", "../lib", "--relative", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"args": ["src/foo.js", "--out-dir", "lib"]
|
||||
"args": ["src/foo.js", "--out-dir", "lib", "--verbose"]
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
src/foo.js -> lib/foo.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -133,4 +133,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "android":"4" }
|
||||
web.immediate { "android":"4" }
|
||||
web.dom.iterable { "android":"4" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -18,4 +18,4 @@ Using plugins:
|
||||
Using polyfills with `entry` option:
|
||||
|
||||
[src/in.js] `import '@babel/polyfill'` was not found.
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -44,4 +44,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "chrome":"55" }
|
||||
web.immediate { "chrome":"55" }
|
||||
web.dom.iterable { "chrome":"55" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -135,4 +135,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "chrome":"54", "ie":"10", "node":"6" }
|
||||
web.immediate { "chrome":"54", "ie":"10", "node":"6" }
|
||||
web.dom.iterable { "chrome":"54", "ie":"10", "node":"6" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -92,4 +92,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "electron":"0.36" }
|
||||
web.immediate { "electron":"0.36" }
|
||||
web.dom.iterable { "electron":"0.36" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -41,4 +41,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "chrome":"55" }
|
||||
web.immediate { "chrome":"55" }
|
||||
web.dom.iterable { "chrome":"55" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -23,4 +23,4 @@ Using plugins:
|
||||
transform-dotall-regex { "firefox":"52", "node":"7.4" }
|
||||
|
||||
Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -22,4 +22,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "chrome":"60" }
|
||||
web.immediate { "chrome":"60" }
|
||||
web.dom.iterable { "chrome":"60" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -153,4 +153,4 @@ Using polyfills with `entry` option:
|
||||
web.timers {}
|
||||
web.immediate {}
|
||||
web.dom.iterable {}
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -139,4 +139,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" }
|
||||
web.immediate { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" }
|
||||
web.dom.iterable { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -36,7 +36,6 @@ Using plugins:
|
||||
Using polyfills with `usage` option:
|
||||
|
||||
[src/in.js] Based on your code and targets, none were added.
|
||||
src/in.js -> lib/in.js
|
||||
|
||||
[src/in2.js] Based on your code and targets, none were added.
|
||||
src/in2.js -> lib/in2.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
@ -13,4 +13,4 @@ Using plugins:
|
||||
Using polyfills with `usage` option:
|
||||
|
||||
[src/in.js] Based on your code and targets, none were added.
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -38,9 +38,8 @@ Using polyfills with `usage` option:
|
||||
[src/in.js] Added following polyfills:
|
||||
es6.promise { "ie":"11" }
|
||||
es6.map { "firefox":"50", "ie":"11" }
|
||||
src/in.js -> lib/in.js
|
||||
|
||||
[src/in2.js] Added following polyfills:
|
||||
regenerator-runtime { "chrome":"52", "firefox":"50", "ie":"11" }
|
||||
web.dom.iterable { "chrome":"52", "firefox":"50", "ie":"11" }
|
||||
src/in2.js -> lib/in2.js
|
||||
🎉 Successfully compiled 2 files with Babel.
|
||||
|
||||
@ -161,4 +161,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" }
|
||||
web.immediate { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" }
|
||||
web.dom.iterable { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
@ -135,4 +135,4 @@ Using polyfills with `entry` option:
|
||||
web.timers { "chrome":"54", "ie":"10", "node":"6.10" }
|
||||
web.immediate { "chrome":"54", "ie":"10", "node":"6.10" }
|
||||
web.dom.iterable { "chrome":"54", "ie":"10", "node":"6.10" }
|
||||
src/in.js -> lib/in.js
|
||||
🎉 Successfully compiled 1 file with Babel.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user