Skip to content

Commit

Permalink
Add flag for disabling port switching (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
jespertheend committed Mar 3, 2021
1 parent b71af1a commit a85bd9d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/serve.js
Expand Up @@ -99,6 +99,8 @@ const getHelp = () => chalk`
--ssl-key Optional path to the SSL/TLS certificate\'s private key
--no-port-switching Do not open a port other than the one specified when it\'s taken.
{bold ENDPOINTS}
Listen endpoints (specified by the {bold --listen} or {bold -l} options above) instruct {cyan serve}
Expand Down Expand Up @@ -206,7 +208,7 @@ const startEndpoint = (endpoint, config, args, previous) => {
: http.createServer(serverHandler);

server.on('error', (err) => {
if (err.code === 'EADDRINUSE' && endpoint.length === 1 && !isNaN(endpoint[0])) {
if (err.code === 'EADDRINUSE' && endpoint.length === 1 && !isNaN(endpoint[0]) && args['--no-port-switching'] !== true) {
startEndpoint([0], config, args, endpoint[0]);
return;
}
Expand Down Expand Up @@ -374,6 +376,7 @@ const loadConfig = async (cwd, entry, args) => {
'--no-etag': Boolean,
'--symlinks': Boolean,
'--cors': Boolean,
'--no-port-switching': Boolean,
'--ssl-cert': String,
'--ssl-key': String,
'-h': '--help',
Expand Down

0 comments on commit a85bd9d

Please sign in to comment.