Skip to content

Commit

Permalink
fix(sirv-cli): hide network address on non-localhost;;
Browse files Browse the repository at this point in the history
Also, specifying `--host` without a value will be an alias for `0.0.0.0` address.
  • Loading branch information
lukeed committed Jun 8, 2019
1 parent 471882b commit aeb4d72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/sirv-cli/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = function (dir, opts) {
toPort(opts.port).then(port => {
let https = !!opts.ssl; // TODO
let isOther = port != opts.port;
let hostname = HOST || opts.host;
let hostname = HOST || opts.host || '0.0.0.0';
server.listen(port, hostname, err => {
if (err) throw err;
if (opts.quiet) return;
Expand All @@ -70,7 +70,7 @@ module.exports = function (dir, opts) {
stdout.write('\n' + PAD + colors.green('Your application is ready~! 🚀\n\n'));
isOther && stdout.write(PAD + colors.italic().dim(`➡ Port ${opts.port} is taken; using ${port} instead\n\n`));
stdout.write(PAD + `${colors.bold('- Local:')} ${local}\n`);
stdout.write(PAD + `${colors.bold('- Network:')} ${network}\n`);
/localhost/i.test(hostname) || stdout.write(PAD + `${colors.bold('- Network:')} ${network}\n`);
let border = '─'.repeat(Math.min(stdout.columns, 36) / 2);
stdout.write('\n' + border + colors.inverse(' LOGS ') + border + '\n\n');
});
Expand Down
4 changes: 2 additions & 2 deletions packages/sirv-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sade('sirv')
.option('-i, --immutable', 'Enable the "immutable" directive for "Cache-Control" header')
.option('-s, --single', 'Serve single-page applications')
.option('-q, --quiet', 'Disable logging to terminal')
.option('-H, --host', 'Hostname to listen', 'localhost')
.option('-p, --port', 'Port to listen', 5000)
.option('-H, --host', 'Hostname to bind', 'localhost')
.option('-p, --port', 'Port to bind', 5000)
.action(boot)
.parse(process.argv);
4 changes: 2 additions & 2 deletions packages/sirv-cli/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ $ sirv start --help
-i, --immutable Enable the "immutable" directive for "Cache-Control" header
-s, --single Serve single-page applications
-q, --quiet Disable logging to terminal
-H, --host Hostname to listen (default localhost)
-p, --port Port to listen (default 5000)
-H, --host Hostname to bind (default localhost)
-p, --port Port to bind (default 5000)
-h, --help Displays this message
```

Expand Down

0 comments on commit aeb4d72

Please sign in to comment.