Skip to content

Commit 66af94d

Browse files
authored
Improve messages when bundle is compiling and done with compiling (#164)
* Improve messages when bundle is compiling and done with compiling * Add compiled with warnings msg
1 parent fcd8c29 commit 66af94d

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

lib/Shared.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ module.exports = function Shared(context) {
4444
options.log(stats.toString(options.stats));
4545
}
4646
if(!options.noInfo && !options.quiet) {
47-
options.log("webpack: bundle is now VALID.");
47+
var msg = "Compiled successfully.";
48+
if(stats.hasErrors()) {
49+
msg = "Failed to compile.";
50+
} else if(stats.hasWarnings()) {
51+
msg = "Compiled with warnings.";
52+
}
53+
options.log("webpack: " + msg);
4854
}
4955
} else {
50-
options.log("webpack: bundle is now INVALID.");
56+
options.log("webpack: Compiling...");
5157
}
5258
},
5359
handleRangeHeaders: function handleRangeHeaders(content, req, res) {

test/Reporter.test.js

+41-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ var simpleStats = {
1515
}
1616
};
1717

18+
var errorStats = {
19+
hasErrors: function() {
20+
return true;
21+
},
22+
hasWarnings: function() {
23+
return false;
24+
}
25+
};
26+
27+
var warningStats = {
28+
hasErrors: function() {
29+
return false;
30+
},
31+
hasWarnings: function() {
32+
return true;
33+
}
34+
};
35+
1836
describe("Reporter", function() {
1937
var plugins = {};
2038
var compiler = {
@@ -33,13 +51,33 @@ describe("Reporter", function() {
3351
});
3452

3553
describe("valid/invalid messages", function() {
36-
it("should show valid message", function(done) {
54+
it("should show compiled successfully message", function(done) {
3755
middleware(compiler);
3856

3957
plugins.done(simpleStats);
4058
setTimeout(function() {
4159
should.strictEqual(console.log.callCount, 2);
42-
should.strictEqual(console.log.calledWith("webpack: bundle is now VALID."), true);
60+
should.strictEqual(console.log.calledWith("webpack: Compiled successfully."), true);
61+
done();
62+
});
63+
});
64+
65+
it("should show compiled successfully message", function(done) {
66+
middleware(compiler);
67+
68+
plugins.done(errorStats);
69+
setTimeout(function() {
70+
should.strictEqual(console.log.calledWith("webpack: Failed to compile."), true);
71+
done();
72+
});
73+
});
74+
75+
it("should show compiled with warnings message", function(done) {
76+
middleware(compiler);
77+
78+
plugins.done(warningStats);
79+
setTimeout(function() {
80+
should.strictEqual(console.log.calledWith("webpack: Compiled with warnings."), true);
4381
done();
4482
});
4583
});
@@ -70,7 +108,7 @@ describe("Reporter", function() {
70108
plugins.invalid();
71109
setTimeout(function() {
72110
should.strictEqual(console.log.callCount, 1);
73-
should.strictEqual(console.log.calledWith("webpack: bundle is now INVALID."), true);
111+
should.strictEqual(console.log.calledWith("webpack: Compiling..."), true);
74112
done();
75113
});
76114
});

0 commit comments

Comments
 (0)