Skip to content

Commit 8a4b070

Browse files
committedNov 20, 2016
Fix colors in CLI not working when using stats as a string
E.g. using `stats: 'errors-only'` resulted in the CLI not displaying colors.
1 parent b072535 commit 8a4b070

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎bin/webpack-dev-server.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ yargs.options({
8787
type: "boolean",
8888
describe: "Open default browser"
8989
},
90+
"color": {
91+
type: "boolean",
92+
alias: "colors",
93+
default: function supportsColor() {
94+
return require("supports-color");
95+
},
96+
group: DISPLAY_GROUP,
97+
describe: "Enables/Disables colors on the console"
98+
},
9099
"info": {
91100
type: "boolean",
92101
group: DISPLAY_GROUP,
@@ -257,7 +266,7 @@ function processOptions(wpOpt) {
257266
}
258267

259268
if(typeof options.stats === "object" && typeof options.stats.colors === "undefined")
260-
options.stats.colors = require("supports-color");
269+
options.stats.colors = argv.color;
261270

262271
if(argv["lazy"])
263272
options.lazy = true;
@@ -411,7 +420,7 @@ function startDevServer(wpOpt, options) {
411420
}
412421

413422
function reportReadiness(uri, options) {
414-
var useColor = options.stats.colors;
423+
var useColor = argv.color;
415424
var startSentence = "Project is running at " + colorInfo(useColor, uri)
416425
if(options.socket) {
417426
startSentence = "Listening to socket at " + colorInfo(useColor, options.socket);

0 commit comments

Comments
 (0)
Please sign in to comment.