Skip to content

Commit

Permalink
fix: port fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 8, 2024
1 parent abab4f6 commit 31bb86c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ cli
.option('--open', 'Open browser', { default: true })
.action(async (options) => {
const host = options.host
const port = await getPort({ port: options.port, portRange: [7777, 9000] })
const port = await getPort({ port: options.port, portRange: [7777, 9000], host })

if (process.env.ESLINT_CONFIG)
options.config ||= process.env.ESLINT_CONFIG
Expand All @@ -75,10 +75,10 @@ cli
globMatchedFiles: options.files,
})

server.listen(port, host)

if (options.open)
await open(`http://${host === '127.0.0.1' ? 'localhost' : host}:${port}`)
server.listen(port, host, async () => {
if (options.open)
await open(`http://${host === '127.0.0.1' ? 'localhost' : host}:${port}`)
})
})

cli.help()
Expand Down

0 comments on commit 31bb86c

Please sign in to comment.