diff --git a/index.js b/index.js index 058bea9..34d9a52 100644 --- a/index.js +++ b/index.js @@ -15,8 +15,7 @@ function apply (options, compiler) { options = options || {}; var context = options.context || compiler.context; options = assign({ - formatter: formatter, - quiet: false + formatter: formatter }, options, { // Default Glob is any directory level of scss and/or sass file, // under webpack's context and specificity changed via globbing patterns diff --git a/lib/run-compilation.js b/lib/run-compilation.js index 9bd60dd..0a29c8f 100644 --- a/lib/run-compilation.js +++ b/lib/run-compilation.js @@ -26,8 +26,8 @@ module.exports = function runCompilation (options, compiler, done) { return file.errored; }); - if (!options.quiet) { - console.log(chalk.yellow(options.formatter(results))); + if (options.quiet === false) { + console.warn(options.formatter(results)); } if (options.failOnError && errors.length) { diff --git a/test/index.test.js b/test/index.test.js index f5fd2da..0a23af3 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1,6 +1,7 @@ 'use strict'; var assign = require('object-assign'); +var td = require('testdouble'); var StyleLintPlugin = require('../'); var pack = require('./helpers/pack'); var webpack = require('./helpers/webpack'); @@ -82,26 +83,6 @@ describe('stylelint-webpack-plugin', function () { }); }); - // TODO use snapshots to ensure something is printed to the console - it.skip('sends messages to console when quiet prop set to false', function () { - var config = { - context: './test/fixtures/syntax-error', - entry: './index', - plugins: [ - new StyleLintPlugin({ - configFile: configFilePath, - quiet: true - }) - ] - }; - - return pack(assign({}, baseConfig, config)) - .then(function (stats) { - expect(stats.compilation.errors).to.have.length(1); - expect(stats.compilation.warnings).to.have.length(0); - }); - }); - it('fails when .stylelintrc is not a proper format', function () { var config = { entry: './index', @@ -121,6 +102,35 @@ describe('stylelint-webpack-plugin', function () { }); }); + context('iff quiet is strictly false', function () { + beforeEach(function () { + td.replace(console, 'warn', td.function()); + }); + + afterEach(function () { + td.reset(); + }); + + it('sends messages to the console', function () { + var config = { + context: './test/fixtures/syntax-error', + entry: './index', + plugins: [ + new StyleLintPlugin({ + configFile: configFilePath, + quiet: false + }) + ] + }; + + return pack(assign({}, baseConfig, config)) + .then(function (stats) { + expect(stats.compilation.errors).to.have.length(1); + td.verify(console.warn(td.matchers.contains('✖'))); + }); + }); + }); + context('without StyleLintPlugin configuration', function () { var config = { context: './test/fixtures/lint-free',