From ccc32d31bf2ad4cea51733485065b5fe32f79167 Mon Sep 17 00:00:00 2001 From: Maksim Date: Tue, 13 Mar 2018 13:16:39 +0300 Subject: [PATCH] Remove unnecessary handler wrapper --- lib/MultiCompiler.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/MultiCompiler.js b/lib/MultiCompiler.js index eefd98cb2..1f941fe7f 100644 --- a/lib/MultiCompiler.js +++ b/lib/MultiCompiler.js @@ -189,16 +189,10 @@ module.exports = class MultiCompiler extends Tapable { watch(watchOptions, handler) { if (this.running) return handler(new ConcurrentCompilationError()); - const finalHandler = (err, stats) => { - this.running = false; - - if (handler !== undefined) handler(err, stats); - }; - let watchings = []; let allStats = this.compilers.map(() => null); let compilerStatus = this.compilers.map(() => false); - if (this.validateDependencies(finalHandler)) { + if (this.validateDependencies(handler)) { this.running = true; this.runWithDependencies( this.compilers, @@ -210,7 +204,7 @@ module.exports = class MultiCompiler extends Tapable { ? watchOptions[compilerIdx] : watchOptions, (err, stats) => { - if (err) finalHandler(err); + if (err) handler(err); if (stats) { allStats[compilerIdx] = stats; compilerStatus[compilerIdx] = "new"; @@ -220,7 +214,7 @@ module.exports = class MultiCompiler extends Tapable { }); compilerStatus.fill(true); const multiStats = new MultiStats(freshStats); - finalHandler(null, multiStats); + handler(null, multiStats); } } if (firstRun && !err) {