angular-cli/packages/@angular/cli/plugins/karma-webpack-emitless-error.ts
2017-03-20 09:10:17 -07:00

21 lines
570 B
TypeScript

// Don't emit anything when there are compilation errors. This is useful for preventing Karma
// from re-running tests when there is a compilation error.
// Workaround for https://github.com/webpack-contrib/karma-webpack/issues/49
export class KarmaWebpackEmitlessError {
constructor() { }
apply(compiler: any): void {
compiler.plugin('done', (stats: any) => {
if (stats.compilation.errors.length > 0) {
stats.stats = [{
toJson: function () {
return this;
},
assets: []
}];
}
});
}
}