From 7a632455ac53c78dfda204f7fe7f2ab2ef06cd8e Mon Sep 17 00:00:00 2001 From: Kees Kluskens Date: Fri, 23 Dec 2016 12:30:30 +0100 Subject: [PATCH 1/2] Improve messages when bundle is compiling and done with compiling --- lib/Shared.js | 4 ++-- test/Reporter.test.js | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/Shared.js b/lib/Shared.js index ef70df256..58b84be84 100644 --- a/lib/Shared.js +++ b/lib/Shared.js @@ -44,10 +44,10 @@ module.exports = function Shared(context) { options.log(stats.toString(options.stats)); } if(!options.noInfo && !options.quiet) { - options.log("webpack: bundle is now VALID."); + options.log("webpack: " + (stats.hasErrors() ? "Failed to compile." : "Compiled successfully.")); } } else { - options.log("webpack: bundle is now INVALID."); + options.log("webpack: Compiling..."); } }, handleRangeHeaders: function handleRangeHeaders(content, req, res) { diff --git a/test/Reporter.test.js b/test/Reporter.test.js index 20f9b9feb..fdd930327 100644 --- a/test/Reporter.test.js +++ b/test/Reporter.test.js @@ -15,6 +15,15 @@ var simpleStats = { } }; +var errorStats = { + hasErrors: function() { + return true; + }, + hasWarnings: function() { + return false; + } +}; + describe("Reporter", function() { var plugins = {}; var compiler = { @@ -33,13 +42,24 @@ describe("Reporter", function() { }); describe("valid/invalid messages", function() { - it("should show valid message", function(done) { + it("should show compiled successfully message", function(done) { middleware(compiler); plugins.done(simpleStats); setTimeout(function() { should.strictEqual(console.log.callCount, 2); - should.strictEqual(console.log.calledWith("webpack: bundle is now VALID."), true); + should.strictEqual(console.log.calledWith("webpack: Compiled successfully."), true); + done(); + }); + }); + + it("should show compiled successfully message", function(done) { + middleware(compiler); + + plugins.done(errorStats); + setTimeout(function() { + should.strictEqual(console.log.callCount, 2); + should.strictEqual(console.log.calledWith("webpack: Failed to compile."), true); done(); }); }); @@ -70,7 +90,7 @@ describe("Reporter", function() { plugins.invalid(); setTimeout(function() { should.strictEqual(console.log.callCount, 1); - should.strictEqual(console.log.calledWith("webpack: bundle is now INVALID."), true); + should.strictEqual(console.log.calledWith("webpack: Compiling..."), true); done(); }); }); From e32929536f93078f340ef89c6f8164adc386a255 Mon Sep 17 00:00:00 2001 From: Kees Kluskens Date: Fri, 23 Dec 2016 21:04:47 +0100 Subject: [PATCH 2/2] Add compiled with warnings msg --- lib/Shared.js | 8 +++++++- test/Reporter.test.js | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/Shared.js b/lib/Shared.js index 58b84be84..8f1ffbb75 100644 --- a/lib/Shared.js +++ b/lib/Shared.js @@ -44,7 +44,13 @@ module.exports = function Shared(context) { options.log(stats.toString(options.stats)); } if(!options.noInfo && !options.quiet) { - options.log("webpack: " + (stats.hasErrors() ? "Failed to compile." : "Compiled successfully.")); + var msg = "Compiled successfully."; + if(stats.hasErrors()) { + msg = "Failed to compile."; + } else if(stats.hasWarnings()) { + msg = "Compiled with warnings."; + } + options.log("webpack: " + msg); } } else { options.log("webpack: Compiling..."); diff --git a/test/Reporter.test.js b/test/Reporter.test.js index fdd930327..3169baf0c 100644 --- a/test/Reporter.test.js +++ b/test/Reporter.test.js @@ -24,6 +24,15 @@ var errorStats = { } }; +var warningStats = { + hasErrors: function() { + return false; + }, + hasWarnings: function() { + return true; + } +}; + describe("Reporter", function() { var plugins = {}; var compiler = { @@ -58,12 +67,21 @@ describe("Reporter", function() { plugins.done(errorStats); setTimeout(function() { - should.strictEqual(console.log.callCount, 2); should.strictEqual(console.log.calledWith("webpack: Failed to compile."), true); done(); }); }); + it("should show compiled with warnings message", function(done) { + middleware(compiler); + + plugins.done(warningStats); + setTimeout(function() { + should.strictEqual(console.log.calledWith("webpack: Compiled with warnings."), true); + done(); + }); + }); + it("should not show valid message if options.quiet is given", function(done) { middleware(compiler, { quiet: true });