Skip to content

Commit

Permalink
fix: use defu for defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 14, 2021
1 parent 80673ea commit f866a61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"clipboardy": "^2.3.0",
"colorette": "^1.2.2",
"defu": "^5.0.0",
"get-port-please": "^2.1.0",
"http-shutdown": "^1.2.2",
"open": "^8.0.5",
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Expand Up @@ -8,6 +8,7 @@ import { cyan, gray, underline, bold } from 'colorette'
import type { SelfsignedOptions } from 'selfsigned'
import { getPort, GetPortInput } from 'get-port-please'
import addShutdown from 'http-shutdown'
import defu from 'defu'

export interface Certificate {
key: string
Expand Down Expand Up @@ -45,7 +46,7 @@ export interface Listener {
}

export async function listen (handle: http.RequestListener, opts: Partial<ListenOptions> = {}): Promise<Listener> {
opts = {
opts = defu(opts, {
port: process.env.PORT || 3000,
hostname: process.env.HOST || '0.0.0.0',
showURL: true,
Expand All @@ -54,9 +55,8 @@ export async function listen (handle: http.RequestListener, opts: Partial<Listen
clipboard: false,
isTest: process.env.NODE_ENV === 'test',
isProd: process.env.NODE_ENV === 'production',
autoClose: true,
...opts
}
autoClose: true
})

if (opts.isTest) {
opts.showURL = false
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -1850,6 +1850,11 @@ defu@^3.2.2:
resolved "https://registry.yarnpkg.com/defu/-/defu-3.2.2.tgz#be20f4cc49b9805d54ee6b610658d53894942e97"
integrity sha512-8UWj5lNv7HD+kB0e9w77Z7TdQlbUYDVWqITLHNqFIn6khrNHv5WQo38Dcm1f6HeNyZf0U7UbPf6WeZDSdCzGDQ==

defu@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/defu/-/defu-5.0.0.tgz#5768f0d402a555bfc4c267246b20f82ce8b5a10b"
integrity sha512-VHg73EDeRXlu7oYWRmmrNp/nl7QkdXUxkQQKig0Zk8daNmm84AbGoC8Be6/VVLJEKxn12hR0UBmz8O+xQiAPKQ==

delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
Expand Down

0 comments on commit f866a61

Please sign in to comment.