From 054642231bdb8b9311bd63a6dad160dee9acccb4 Mon Sep 17 00:00:00 2001 From: Sam Swarr Date: Tue, 15 Mar 2016 12:08:32 -0700 Subject: [PATCH] Add ability to silence packager logs to stdout Summary:We use a few different modules to output logs to stdout when building a bundle with the packager: - ##js/react-native-github/packager/react-packager/src/Activity/index.js## - ##js/react-native-github/local-cli/util/log.js## - ##https://www.npmjs.com/package/progress## This diff also adds a ##silent## option to the packager ##Server##, which, when ##true##, will not create a ##progress## instance for the transformer. Reviewed By: martinbigio Differential Revision: D3048739 fb-gh-sync-id: a4c6caf36f5127946593f4a0a349fa145ad0d4e6 shipit-source-id: a4c6caf36f5127946593f4a0a349fa145ad0d4e6 --- react-packager/src/Bundler/index.js | 8 ++++++-- react-packager/src/Server/index.js | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/react-packager/src/Bundler/index.js b/react-packager/src/Bundler/index.js index 3ec53f34..75d89877 100644 --- a/react-packager/src/Bundler/index.js +++ b/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/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index fe49ebbb..c52762f6 100644 --- a/react-packager/src/Server/index.js +++ b/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({