diff --git a/src/index.ts b/src/index.ts index 50dd0b1..6aa1680 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,7 +40,8 @@ export interface Listener { url: string, server: http.Server | https.Server, close: () => Promise, - open: () => Promise + open: () => Promise, + showURL: () => void } export async function listen (handle: http.RequestListener, opts: Partial = {}): Promise { @@ -103,7 +104,7 @@ export async function listen (handle: http.RequestListener, opts: Partial { opts.clipboard = false }) } - if (opts.showURL) { + const showURL = () => { const add = opts.clipboard ? gray('(copied to clipboard)') : '' const lines = [] lines.push(` > Local: ${formatURL(url)} ${add}`) @@ -116,6 +117,10 @@ export async function listen (handle: http.RequestListener, opts: Partial { const { default: open } = await import('open') await open(url).catch(() => { }) @@ -132,6 +137,7 @@ export async function listen (handle: http.RequestListener, opts: Partial