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) {