From 65d2153638c15eb59976b1985eaf04d554ddb187 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 14:14:26 -0500 Subject: [PATCH] prefer early return for config.stats tests --- lib/pipeline/webpackProcess.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/pipeline/webpackProcess.js b/lib/pipeline/webpackProcess.js index 1010e36e..8e75cdc1 100644 --- a/lib/pipeline/webpackProcess.js +++ b/lib/pipeline/webpackProcess.js @@ -77,27 +77,28 @@ class WebpackProcess extends ProcessWrapper { if (err) { return callback(errorMessage(err)); } + if (!config.stats || config.stats === 'none') { + return callback(); + } try { - if (config.stats && config.stats !== 'none') { - this._log('info', 'writing file '+ ('.embark/stats.report').bold.dim); - await writeFile( - fs.dappPath('.embark/stats.report'), - stats.toString(config.stats) - ); - this._log('info', 'writing file ' + ('.embark/stats.json').bold.dim); - await writeFile( - fs.dappPath('.embark/stats.json'), - JSON.stringify(stats.toJson(config.stats)) - ); + this._log('info', 'writing file '+ ('.embark/stats.report').bold.dim); + await writeFile( + fs.dappPath('.embark/stats.report'), + stats.toString(config.stats) + ); + this._log('info', 'writing file ' + ('.embark/stats.json').bold.dim); + await writeFile( + fs.dappPath('.embark/stats.json'), + JSON.stringify(stats.toJson(config.stats)) + ); + if (stats.hasErrors()) { + const errors = stats.toJson(config.stats).errors.join('\n'); + return callback(errors); } + callback(); } catch (e) { return callback(errorMessage(e)); } - if (config.stats && stats.hasErrors()) { - const errors = stats.toJson(config.stats).errors.join('\n'); - return callback(errors); - } - callback(); }); } }