Skip to content

Commit

Permalink
Immediately exit run command if server name collision detected
Browse files Browse the repository at this point in the history
  • Loading branch information
svicalifornia committed Jun 24, 2022
1 parent 0d7eba9 commit 050f3ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
const serverAddress = `http://localhost:${port}`;

process.env.PORT = port;
servers.add(serverAddress, opts);
if (!servers.add(serverAddress, opts)) process.exit(1);

signals.forEach(signal => process.on(signal, cleanAndExit));

Expand Down
4 changes: 3 additions & 1 deletion src/cli/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function add(param, opts = {}) {
fs.writeFileSync(file, data);

// if we're mapping a domain to a URL there's no additional info to output
if (conf.target) return;
if (conf.target) return conf;

// if we're mapping a domain to a local server add some info
if (conf.out) {
Expand All @@ -123,6 +123,8 @@ function add(param, opts = {}) {
if (!opts.p) {
console.log("Port Random port (use '-p 1337' to set a fixed port)");
}

return conf;
}

function rm(opts = {}) {
Expand Down

0 comments on commit 050f3ba

Please sign in to comment.