Remove unnecessary handler wrapper

This commit is contained in:
Maksim 2018-03-13 13:16:39 +03:00
parent ea6e173551
commit ccc32d31bf
1 changed files with 3 additions and 9 deletions

View File

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