prefer early return for config.stats tests

This commit is contained in:
Michael Bradley, Jr 2018-08-20 14:14:26 -05:00
parent 9e62d9c1a9
commit 65d2153638
1 changed files with 17 additions and 16 deletions

View File

@ -77,8 +77,10 @@ class WebpackProcess extends ProcessWrapper {
if (err) { if (err) {
return callback(errorMessage(err)); return callback(errorMessage(err));
} }
if (!config.stats || config.stats === 'none') {
return callback();
}
try { try {
if (config.stats && config.stats !== 'none') {
this._log('info', 'writing file '+ ('.embark/stats.report').bold.dim); this._log('info', 'writing file '+ ('.embark/stats.report').bold.dim);
await writeFile( await writeFile(
fs.dappPath('.embark/stats.report'), fs.dappPath('.embark/stats.report'),
@ -89,15 +91,14 @@ class WebpackProcess extends ProcessWrapper {
fs.dappPath('.embark/stats.json'), fs.dappPath('.embark/stats.json'),
JSON.stringify(stats.toJson(config.stats)) JSON.stringify(stats.toJson(config.stats))
); );
} if (stats.hasErrors()) {
} catch (e) {
return callback(errorMessage(e));
}
if (config.stats && stats.hasErrors()) {
const errors = stats.toJson(config.stats).errors.join('\n'); const errors = stats.toJson(config.stats).errors.join('\n');
return callback(errors); return callback(errors);
} }
callback(); callback();
} catch (e) {
return callback(errorMessage(e));
}
}); });
} }
} }