From f866a6134f068bda1e20619a896a2b792c96e315 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 14 Oct 2021 15:51:58 +0200 Subject: [PATCH] fix: use defu for defaults --- package.json | 1 + src/index.ts | 8 ++++---- yarn.lock | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8f32a83..55ab889 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index 6aa1680..15f386f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 @@ -45,7 +46,7 @@ export interface Listener { } export async function listen (handle: http.RequestListener, opts: Partial = {}): Promise { - opts = { + opts = defu(opts, { port: process.env.PORT || 3000, hostname: process.env.HOST || '0.0.0.0', showURL: true, @@ -54,9 +55,8 @@ export async function listen (handle: http.RequestListener, opts: Partial