Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve messages when bundle is compiling and done with compiling #164

Merged
merged 2 commits into from
Dec 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/Shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ module.exports = function Shared(context) {
options.log(stats.toString(options.stats));
}
if(!options.noInfo && !options.quiet) {
options.log("webpack: bundle is now VALID.");
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: bundle is now INVALID.");
options.log("webpack: Compiling...");
}
},
handleRangeHeaders: function handleRangeHeaders(content, req, res) {
Expand Down
44 changes: 41 additions & 3 deletions test/Reporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ var simpleStats = {
}
};

var errorStats = {
hasErrors: function() {
return true;
},
hasWarnings: function() {
return false;
}
};

var warningStats = {
hasErrors: function() {
return false;
},
hasWarnings: function() {
return true;
}
};

describe("Reporter", function() {
var plugins = {};
var compiler = {
Expand All @@ -33,13 +51,33 @@ 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.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();
});
});
Expand Down Expand Up @@ -70,7 +108,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();
});
});
Expand Down