From 3dcf1f90c8ea98e28f3bf0321a3a0ff04afb5c90 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Wed, 16 Nov 2016 11:54:17 -0500 Subject: [PATCH 1/2] Only console.log the debug info once --- src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 304dcd90..c3516bbe 100644 --- a/src/index.js +++ b/src/index.js @@ -132,6 +132,8 @@ export const validateWhitelistOption = (whitelistOpt = []) => { return whitelistOpt; }; +let alreadyLogged = false; + export default function buildPreset(context, opts = {}) { const loose = validateLooseOption(opts.loose); const moduleType = validateModulesOption(opts.modules); @@ -142,7 +144,10 @@ export default function buildPreset(context, opts = {}) { let transformations = Object.keys(pluginList) .filter((pluginName) => isPluginRequired(targets, pluginList[pluginName])); - if (debug) { + if (debug && !alreadyLogged) { + alreadyLogged = true; + + console.log("babel-preset-env: `DEBUG` option"); console.log(""); console.log(`Using targets: ${JSON.stringify(targets, null, 2)}`); console.log(""); From dd312b8729b1a119d9637ce8d7b496fdc770ef19 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Wed, 16 Nov 2016 12:27:34 -0500 Subject: [PATCH 2/2] [skip ci] --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index c3516bbe..bbeefdc7 100644 --- a/src/index.js +++ b/src/index.js @@ -132,7 +132,7 @@ export const validateWhitelistOption = (whitelistOpt = []) => { return whitelistOpt; }; -let alreadyLogged = false; +let hasBeenLogged = false; export default function buildPreset(context, opts = {}) { const loose = validateLooseOption(opts.loose); @@ -144,8 +144,8 @@ export default function buildPreset(context, opts = {}) { let transformations = Object.keys(pluginList) .filter((pluginName) => isPluginRequired(targets, pluginList[pluginName])); - if (debug && !alreadyLogged) { - alreadyLogged = true; + if (debug && !hasBeenLogged) { + hasBeenLogged = true; console.log("babel-preset-env: `DEBUG` option"); console.log("");