Skip to content

Commit

Permalink
fixes incorrect CLI stats output
Browse files Browse the repository at this point in the history
fixes #4141
fixes #4118
  • Loading branch information
sokra committed Jan 31, 2017
1 parent 9e644ac commit da386b2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
31 changes: 21 additions & 10 deletions bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,36 +219,45 @@ function processOptions(options) {
outputOptions.cachedAssets = false;

ifArg("display-chunks", function(bool) {
outputOptions.modules = !bool;
outputOptions.chunks = bool;
if(bool) {
outputOptions.modules = false;
outputOptions.chunks = true;
}
});

ifArg("display-entrypoints", function(bool) {
outputOptions.entrypoints = bool;
if(bool)
outputOptions.entrypoints = true;
});

ifArg("display-reasons", function(bool) {
outputOptions.reasons = bool;
if(bool)
outputOptions.reasons = true;
});

ifArg("display-depth", function(bool) {
outputOptions.depth = bool;
if(bool)
outputOptions.depth = true;
});

ifArg("display-used-exports", function(bool) {
outputOptions.usedExports = bool;
if(bool)
outputOptions.usedExports = true;
});

ifArg("display-provided-exports", function(bool) {
outputOptions.providedExports = bool;
if(bool)
outputOptions.providedExports = true;
});

ifArg("display-error-details", function(bool) {
outputOptions.errorDetails = bool;
if(bool)
outputOptions.errorDetails = true;
});

ifArg("display-origins", function(bool) {
outputOptions.chunkOrigins = bool;
if(bool)
outputOptions.chunkOrigins = true;
});

ifArg("display-max-modules", function(value) {
Expand Down Expand Up @@ -337,7 +346,9 @@ function processOptions(options) {
process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n");
} else if(stats.hash !== lastHash) {
lastHash = stats.hash;
process.stdout.write(stats.toString(outputOptions) + "\n");
var statsString = stats.toString(outputOptions);
if(statsString)
process.stdout.write(statsString + "\n");
}
if(!options.watch && stats.hasErrors()) {
process.on("exit", function() {
Expand Down
1 change: 1 addition & 0 deletions test/binCases/stats/none/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "foo";
8 changes: 8 additions & 0 deletions test/binCases/stats/none/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";

module.exports = function testAssertions(code, stdout, stderr) {
code.should.be.eql(0);

stdout.should.be.empty();
stderr.should.be.empty();
};
6 changes: 6 additions & 0 deletions test/binCases/stats/none/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var path = require("path");

module.exports = {
entry: path.resolve(__dirname, "./index"),
stats: "none"
};
7 changes: 4 additions & 3 deletions test/binCases/stats/single-config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ module.exports = function testAssertions(code, stdout, stderr) {
stdout[1].should.containEql("Version: ");
stdout[2].should.containEql("Time: ");
stdout[4].should.containEql("\u001b[1m\u001b[32mnull.js\u001b[39m\u001b[22m");
stdout[5].should.not.containEql("./index.js");
stdout[5].should.not.containEql("[built]");
stdout[5].should.containEql("1 hidden module");
stdout[5].should.containEql("chunk");
stdout[6].should.not.containEql("./index.js");
stdout[6].should.not.containEql("[built]");
stdout[6].should.containEql("1 hidden module");

stderr.should.be.empty();
};

0 comments on commit da386b2

Please sign in to comment.