Skip to content

Commit beaef81

Browse files
committed
Make CLI startup output more fancy
Fixes #681
1 parent 58a5228 commit beaef81

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

bin/webpack-dev-server.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ function versionInfo() {
2222
"webpack " + require("webpack/package.json").version;
2323
}
2424

25+
function colorize(useColor, msg) {
26+
if(useColor)
27+
// Make text blue and bold, so it *pops*
28+
return "\u001b[1m\u001b[34m" + msg + "\u001b[39m\u001b[22m";
29+
return msg;
30+
}
31+
2532
var yargs = require("yargs")
2633
.usage(versionInfo() +
2734
"\nUsage: http://webpack.github.io/docs/webpack-dev-server.html");
@@ -375,18 +382,19 @@ function processOptions(wpOpt) {
375382
}
376383

377384
function reportReadiness(uri, options) {
378-
var startSentence = "Project is running at " + uri;
385+
var useColor = options.stats.colors;
386+
var startSentence = "Project is running at " + colorize(useColor, uri)
379387
if(options.socket) {
380-
startSentence = "Listening to socket at " + options.socket;
388+
startSentence = "Listening to socket at " + colorize(useColor, options.socket);
381389
}
382390
console.log((argv["progress"] ? "\n" : "") + startSentence);
383391

384-
console.log("webpack output is served from " + options.publicPath);
392+
console.log("webpack output is served from " + colorize(useColor, options.publicPath));
385393
var contentBase = Array.isArray(options.contentBase) ? options.contentBase.join(", ") : options.contentBase;
386394
if(contentBase)
387-
console.log("Content not from webpack is served from " + contentBase);
395+
console.log("Content not from webpack is served from " + colorize(useColor, contentBase));
388396
if(options.historyApiFallback)
389-
console.log("404s will fallback to %s", options.historyApiFallback.index || "/index.html");
397+
console.log("404s will fallback to " + colorize(useColor, options.historyApiFallback.index || "/index.html"));
390398
if(options.open)
391399
open(uri);
392400
}

0 commit comments

Comments
 (0)