Skip to content

Commit

Permalink
splat listen() args to only specify host when supplied (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Mar 10, 2018
1 parent 3b33de0 commit 3191eea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/micro.js
Expand Up @@ -17,7 +17,6 @@ const logError = require('../lib/error')
// Check if the user defined any options
const flags = parseArgs(process.argv.slice(2), {
default: {
host: '::',
port: 3000
},
alias: {
Expand Down Expand Up @@ -101,7 +100,12 @@ async function start() {
process.exit(1)
})

server.listen(flags.port, flags.host, () => {
const listenArgs = [flags.port || 0]
if (flags.host) {
listenArgs.push(flags.host)
}

server.listen(...listenArgs, () => {
const details = server.address()

process.on('SIGTERM', () => {
Expand Down

0 comments on commit 3191eea

Please sign in to comment.