Skip to content

Commit ecd0219

Browse files
committed
return error object for compiler dependency errors
1 parent 934534e commit ecd0219

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/MultiCompiler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ module.exports = class MultiCompiler extends Tapable {
114114
errors.unshift("Circular dependency found in compiler dependencies.");
115115
}
116116
if(errors.length > 0) {
117-
callback(errors.join("\n"));
117+
const message = errors.join("\n");
118+
callback(new Error(message));
118119
return false;
119120
}
120121
return true;

test/MultiCompiler.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ describe("MultiCompiler", () => {
419419
env.compiler1WatchCallbacks.length.should.be.exactly(0);
420420
env.compiler2WatchCallbacks.length.should.be.exactly(0);
421421
env.callback.callCount.should.be.exactly(1);
422-
env.callback.getCall(0).args[0].should.match(/`compiler2` not found/);
422+
env.callback.getCall(0).args[0].should.be.Error();
423+
should(env.callback.getCall(0).args[1]).be.undefined();
423424
});
424425
});
425426

@@ -445,7 +446,8 @@ describe("MultiCompiler", () => {
445446
env.compiler1WatchCallbacks.length.should.be.exactly(0);
446447
env.compiler2WatchCallbacks.length.should.be.exactly(0);
447448
env.callback.callCount.should.be.exactly(1);
448-
env.callback.getCall(0).args[0].should.equal("Circular dependency found in compiler dependencies.");
449+
env.callback.getCall(0).args[0].should.be.Error();
450+
should(env.callback.getCall(0).args[1]).be.undefined();
449451
});
450452
});
451453
});
@@ -557,7 +559,8 @@ describe("MultiCompiler", () => {
557559
env.compiler1RunCallbacks.length.should.be.exactly(0);
558560
env.compiler2RunCallbacks.length.should.be.exactly(0);
559561
env.callback.callCount.should.be.exactly(1);
560-
env.callback.getCall(0).args[0].should.match(/`compiler2` not found/);
562+
env.callback.getCall(0).args[0].should.be.Error();
563+
should(env.callback.getCall(0).args[1]).be.undefined();
561564
});
562565
});
563566

@@ -578,7 +581,8 @@ describe("MultiCompiler", () => {
578581
env.compiler1RunCallbacks.length.should.be.exactly(0);
579582
env.compiler2RunCallbacks.length.should.be.exactly(0);
580583
env.callback.callCount.should.be.exactly(1);
581-
env.callback.getCall(0).args[0].should.equal("Circular dependency found in compiler dependencies.");
584+
env.callback.getCall(0).args[0].should.be.Error();
585+
should(env.callback.getCall(0).args[1]).be.undefined();
582586
});
583587
});
584588
});

0 commit comments

Comments
 (0)