Skip to content

Commit 98529b5

Browse files
committed
Make finding an open port work
1 parent 0206aa3 commit 98529b5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ const getMod = file => {
2929

3030
module.exports = (file, flags) => {
3131
const server = serve(getMod(file))
32+
3233
let port = flags.port
34+
let host = flags.host
3335

3436
detect(port).then(open => {
3537
let inUse = open !== port
@@ -43,7 +45,11 @@ module.exports = (file, flags) => {
4345
}
4446
}
4547

46-
server.listen(port, flags.host, async err => {
48+
if (host === '0.0.0.0') {
49+
host = null
50+
}
51+
52+
server.listen(port, host, async err => {
4753
if (err) {
4854
console.error('micro:', err.stack)
4955
process.exit(1)

lib/listening.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const copyToClipboard = async text => {
1212
}
1313
}
1414

15-
module.exports = async (server, current, inUse) => {
15+
module.exports = async (server, inUse) => {
1616
const details = server.address()
1717
const ipAddress = ip.address()
1818
const url = `http://${ipAddress}:${details.port}`

0 commit comments

Comments
 (0)