peach a19a732be8 commit message | před 2 roky | |
---|---|---|
.. | ||
dist | před 2 roky | |
LICENSE | před 2 roky | |
README.md | před 2 roky | |
package.json | před 2 roky |
Get an available TCP port to listen
Install package:
yarn add get-port-please
# or
or npm install get-port-please
// ESM
import { getPort, checkPort, getRandomPort, waitForPort } from 'get-port-please'
// CommonJS
const { getPort, checkPort, getRandomPort, waitForPort } = require('get-port-please')
getPort(options?: GetPortOptions): Promise<number>
checkPort(port: number, host?: string): Promise<number | false>
waitForPort(port: number, options): Promise<number | false>
Try sequence is: port > ports > memo > random
interface GetPortOptions {
name?: string
random?: boolean
port?: number
portRange?: [from: number, to: number]
ports?: number[]
host?: string
memoDir?: string
memoName?: string
}
name
Unique name for port memorizing. Default is default
.
random
If enabled, port
and ports
will be ignored. Default is false
.
port
First port to check. Default is process.env.PORT || 3000
ports
Alternative ports to check.
portRange
Alternative port range to check. Deefault is [3000,3100]
host
The host to check. Default is process.env.HOST
otherwise all available hosts will be checked.
memoDir
/ memoName
Options passed to fs-memo
node_modules/get-port/dist
.get-port
MIT