diff --git a/local-cli/util/log.js b/local-cli/util/log.js index 018c5275a2197a..16bbbae58e7a64 100644 --- a/local-cli/util/log.js +++ b/local-cli/util/log.js @@ -8,8 +8,17 @@ */ 'use strict'; +var _enabled = true; + +function disable() { + _enabled = false; +} + function log(stream, module) { return function() { + if (!_enabled) { + return; + } const message = Array.prototype.slice.call(arguments).join(' '); stream.write(module + ': ' + message + '\n'); }; @@ -17,3 +26,4 @@ function log(stream, module) { module.exports.out = log.bind(null, process.stdout); module.exports.err = log.bind(null, process.stderr); +module.exports.disable = disable; diff --git a/packager/react-packager/src/Bundler/index.js b/packager/react-packager/src/Bundler/index.js index 3ec53f3407dd05..75d89877d681e2 100644 --- a/packager/react-packager/src/Bundler/index.js +++ b/packager/react-packager/src/Bundler/index.js @@ -81,6 +81,10 @@ const validateOpts = declareOpts({ type: 'number', required: false, }, + silent: { + type: 'boolean', + default: false, + }, }); class Bundler { @@ -352,8 +356,8 @@ class Bundler { const modulesByName = Object.create(null); if (!resolutionResponse) { - let onProgess; - if (process.stdout.isTTY) { + let onProgess = noop; + if (process.stdout.isTTY && !this._opts.silent) { const bar = new ProgressBar( 'transformed :current/:total (:percent)', {complete: '=', incomplete: ' ', width: 40, total: 1}, diff --git a/packager/react-packager/src/Server/index.js b/packager/react-packager/src/Server/index.js index fe49ebbb354d75..c52762f6c44c66 100644 --- a/packager/react-packager/src/Server/index.js +++ b/packager/react-packager/src/Server/index.js @@ -73,6 +73,10 @@ const validateOpts = declareOpts({ type: 'string', required: false, }, + silent: { + type: 'boolean', + default: false, + }, }); const bundleOpts = declareOpts({