Skip to content

Commit 4e47a5e

Browse files
committed
fix: quiet flag only prints when set to false
1 parent e2f33b8 commit 4e47a5e

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ function apply (options, compiler) {
1515
options = options || {};
1616
var context = options.context || compiler.context;
1717
options = assign({
18-
formatter: formatter,
19-
quiet: false
18+
formatter: formatter
2019
}, options, {
2120
// Default Glob is any directory level of scss and/or sass file,
2221
// under webpack's context and specificity changed via globbing patterns

lib/run-compilation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ module.exports = function runCompilation (options, compiler, done) {
2626
return file.errored;
2727
});
2828

29-
if (!options.quiet) {
30-
console.log(chalk.yellow(options.formatter(results)));
29+
if (options.quiet === false) {
30+
console.warn(options.formatter(results));
3131
}
3232

3333
if (options.failOnError && errors.length) {

test/index.test.js

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
var assign = require('object-assign');
4+
var td = require('testdouble');
45
var StyleLintPlugin = require('../');
56
var pack = require('./helpers/pack');
67
var webpack = require('./helpers/webpack');
@@ -82,26 +83,6 @@ describe('stylelint-webpack-plugin', function () {
8283
});
8384
});
8485

85-
// TODO use snapshots to ensure something is printed to the console
86-
it.skip('sends messages to console when quiet prop set to false', function () {
87-
var config = {
88-
context: './test/fixtures/syntax-error',
89-
entry: './index',
90-
plugins: [
91-
new StyleLintPlugin({
92-
configFile: configFilePath,
93-
quiet: true
94-
})
95-
]
96-
};
97-
98-
return pack(assign({}, baseConfig, config))
99-
.then(function (stats) {
100-
expect(stats.compilation.errors).to.have.length(1);
101-
expect(stats.compilation.warnings).to.have.length(0);
102-
});
103-
});
104-
10586
it('fails when .stylelintrc is not a proper format', function () {
10687
var config = {
10788
entry: './index',
@@ -121,6 +102,35 @@ describe('stylelint-webpack-plugin', function () {
121102
});
122103
});
123104

105+
context('iff quiet is strictly false', function () {
106+
beforeEach(function () {
107+
td.replace(console, 'warn', td.function());
108+
});
109+
110+
afterEach(function () {
111+
td.reset();
112+
});
113+
114+
it('sends messages to the console', function () {
115+
var config = {
116+
context: './test/fixtures/syntax-error',
117+
entry: './index',
118+
plugins: [
119+
new StyleLintPlugin({
120+
configFile: configFilePath,
121+
quiet: false
122+
})
123+
]
124+
};
125+
126+
return pack(assign({}, baseConfig, config))
127+
.then(function (stats) {
128+
expect(stats.compilation.errors).to.have.length(1);
129+
td.verify(console.warn(td.matchers.contains('✖')));
130+
});
131+
});
132+
});
133+
124134
context('without StyleLintPlugin configuration', function () {
125135
var config = {
126136
context: './test/fixtures/lint-free',

0 commit comments

Comments
 (0)