diff --git a/packages/babel-cli/bin/babel/dir.js b/packages/babel-cli/bin/babel/dir.js index 4858679b6a..5a0a8511b2 100644 --- a/packages/babel-cli/bin/babel/dir.js +++ b/packages/babel-cli/bin/babel/dir.js @@ -28,7 +28,7 @@ module.exports = function (commander, filenames) { outputFileSync(dest, data.code); - console.log(src + " -> " + dest); + util.log(src + " -> " + dest); }; var handleFile = function (src, filename) { diff --git a/packages/babel-cli/bin/babel/file.js b/packages/babel-cli/bin/babel/file.js index dedf1ee0aa..9b2f9db4a5 100644 --- a/packages/babel-cli/bin/babel/file.js +++ b/packages/babel-cli/bin/babel/file.js @@ -135,7 +135,7 @@ module.exports = function (commander, filenames, opts) { ignoreInitial: true }).on("all", function (type, filename) { if (type === "add" || type === "change") { - console.log(type, filename); + util.log(type + " " + filename); try { walk(); } catch (err) { diff --git a/packages/babel-cli/bin/babel/index.js b/packages/babel-cli/bin/babel/index.js index 3be8127d1d..fd1f027357 100755 --- a/packages/babel-cli/bin/babel/index.js +++ b/packages/babel-cli/bin/babel/index.js @@ -45,6 +45,7 @@ commander.option("-w, --watch", "Recompile files on changes"); commander.option("-o, --out-file [out]", "Compile all input files into a single file"); commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory"); commander.option("-D, --copy-files", "When compiling a directory copy over non-compilable files"); +commander.option("-q, --quiet", "Don't log anything"); commander.on("--help", function () { var outKeys = function (title, obj) { diff --git a/packages/babel-cli/bin/babel/util.js b/packages/babel-cli/bin/babel/util.js index 1a53d68772..8ade28d1d6 100644 --- a/packages/babel-cli/bin/babel/util.js +++ b/packages/babel-cli/bin/babel/util.js @@ -25,6 +25,10 @@ exports.addSourceMappingUrl = function (code, loc) { return code + "\n//# sourceMappingURL=" + path.basename(loc); }; +exports.log = function (msg) { + if (!commander.quiet) console.log(msg); +}; + exports.transform = function (filename, code, opts) { opts = _.defaults(opts || {}, index.opts); opts.filename = filename;