Skip to content

Commit

Permalink
fix: resolve defaults at getPort
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 12, 2021
1 parent 09c396a commit dcab479
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ export interface GetPortOptions {

export type GetPortInput = Partial<GetPortOptions> | number | string

const defaults = {
name: 'default',
random: false,
port: parseInt(process.env.PORT || '') || 3000,
ports: [4000, 5000, 6000, 7000],
host: process.env.HOST || '0.0.0.0',
memoName: 'port'
}

export async function getPort (config?: GetPortInput): Promise<number> {
if (typeof config === 'number' || typeof config === 'string') {
config = { port: parseInt(config + '') }
}

const options = { ...defaults, ...config } as GetPortOptions
const options = {
name: 'default',
random: false,
port: parseInt(process.env.PORT || '') || 3000,
ports: [4000, 5000, 6000, 7000],
host: process.env.HOST || '0.0.0.0',
memoName: 'port',
...config
} as GetPortOptions

const portsToCheck: number[] = []

Expand Down

0 comments on commit dcab479

Please sign in to comment.