@palettelab/cli 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ports.js +2 -2
- package/package.json +1 -1
package/lib/ports.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const net = require("net")
|
|
4
4
|
|
|
5
|
-
function canBindPort(port, host = "
|
|
5
|
+
function canBindPort(port, host = "0.0.0.0") {
|
|
6
6
|
return new Promise((resolve) => {
|
|
7
7
|
const server = net.createServer()
|
|
8
8
|
server.once("error", () => resolve(false))
|
|
@@ -13,7 +13,7 @@ function canBindPort(port, host = "127.0.0.1") {
|
|
|
13
13
|
})
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async function findFreePort(preferred, { host = "
|
|
16
|
+
async function findFreePort(preferred, { host = "0.0.0.0", maxAttempts = 100 } = {}) {
|
|
17
17
|
const start = Number(preferred)
|
|
18
18
|
if (!Number.isInteger(start) || start <= 0 || start > 65535) {
|
|
19
19
|
throw new Error(`invalid port: ${preferred}`)
|