Skip to content

Commit 07d57d6

Browse files
crash7JaKXz
authored andcommitted
feat: output errors in error constructor (#104)
1 parent 59904a2 commit 07d57d6

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

lib/run-compilation.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var chalk = require('chalk');
43
var R = require('ramda');
54
var linter = require('./linter');
65
var errorMessage = require('./constants').errorMessage;
@@ -41,12 +40,12 @@ module.exports = function runCompilation (options, compiler, done) {
4140

4241
compiler.plugin('after-emit', function afterEmit (compilation, callback) {
4342
if (warnings.length) {
44-
compilation.warnings.push(chalk.yellow(options.formatter(warnings)));
43+
compilation.warnings.push(new Error(options.formatter(warnings)));
4544
warnings = [];
4645
}
4746

4847
if (errors.length) {
49-
compilation.errors.push(chalk.red(options.formatter(errors)));
48+
compilation.errors.push(new Error(options.formatter(errors)));
5049
errors = [];
5150
}
5251

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
},
3636
"dependencies": {
3737
"arrify": "^1.0.1",
38-
"chalk": "^1.1.3",
3938
"minimatch": "^3.0.3",
4039
"object-assign": "^4.1.0",
4140
"ramda": "^0.24.1",

test/index.test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ describe('stylelint-webpack-plugin', function () {
3333
return pack(assign({}, baseConfig, { context: path.resolve('./test/fixtures/multiple-sources') }))
3434
.then(function (stats) {
3535
expect(stats.compilation.errors).to.have.length(1);
36-
expect(stats.compilation.errors[0]).to.contain('test/fixtures/multiple-sources/_second.scss');
37-
expect(stats.compilation.errors[0]).to.contain('test/fixtures/multiple-sources/test.scss');
36+
expect(stats.compilation.errors[0]).to.be.an.instanceof(Error);
37+
expect(stats.compilation.errors[0].message).to.contain('test/fixtures/multiple-sources/_second.scss');
38+
expect(stats.compilation.errors[0].message).to.contain('test/fixtures/multiple-sources/test.scss');
3839
});
3940
});
4041

@@ -206,7 +207,8 @@ describe('stylelint-webpack-plugin', function () {
206207
.then(function (stats) {
207208
expect(stats.compilation.errors).to.have.length(0);
208209
expect(stats.compilation.warnings).to.have.length(1);
209-
expect(stats.compilation.warnings[0]).to.contain('✖');
210+
expect(stats.compilation.warnings[0]).to.be.an.instanceof(Error);
211+
expect(stats.compilation.warnings[0].message).to.contain('✖');
210212
});
211213
});
212214

@@ -215,7 +217,8 @@ describe('stylelint-webpack-plugin', function () {
215217
.then(function (stats) {
216218
expect(stats.compilation.errors).to.have.length(0);
217219
expect(stats.compilation.warnings).to.have.length(1);
218-
expect(stats.compilation.warnings[0]).to.contain('⚠');
220+
expect(stats.compilation.warnings[0]).to.be.an.instanceof(Error);
221+
expect(stats.compilation.warnings[0].message).to.contain('⚠');
219222
});
220223
});
221224
});

0 commit comments

Comments
 (0)