Skip to content

Commit 1a26ab4

Browse files
alsoshellscape
authored andcommitted
fix #752: allow --port 0 again (#918)
* fix #752: don't rely on truthiness for port * better variable name
1 parent 9a7693c commit 1a26ab4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bin/webpack-dev-server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function colorError(useColor, msg) {
3939
return msg;
4040
}
4141

42+
const defaultTo = (value, def) => value == null ? def : value;
43+
4244
const yargs = require("yargs")
4345
.usage(`${versionInfo()
4446
}\nUsage: https://webpack.js.org/configuration/dev-server/`);
@@ -317,8 +319,8 @@ function processOptions(wpOpt) {
317319
// that wouldn't throw errors. E.g. both argv.port and options.port
318320
// were specified, but since argv.port is 8080, options.port will be
319321
// tried first instead.
320-
options.port = argv.port === DEFAULT_PORT ? (options.port || argv.port) : (argv.port || options.port);
321-
if(options.port) {
322+
options.port = argv.port === DEFAULT_PORT ? defaultTo(options.port, argv.port) : defaultTo(argv.port, options.port);
323+
if(options.port != null) {
322324
startDevServer(wpOpt, options);
323325
return;
324326
}

0 commit comments

Comments
 (0)