This commit is contained in:
Daniel Flanagan 2024-06-07 15:12:50 -05:00
parent 943351e374
commit bf2bd6ad54

8
mod.ts
View file

@ -1,5 +1,6 @@
import { Command } from 'https://deno.land/x/cliffy@v1.0.0-rc.4/command/mod.ts' import { Command } from 'https://deno.land/x/cliffy@v1.0.0-rc.4/command/mod.ts'
import { z } from 'https://deno.land/x/zod@v3.23.8/mod.ts' import { z } from 'https://deno.land/x/zod@v3.23.8/mod.ts'
import { open } from 'https://deno.land/x/opener/mod.ts'
const sockets: Set<WebSocket> = new Set([]) const sockets: Set<WebSocket> = new Set([])
@ -46,11 +47,8 @@ async function openBrowser(args: Args): Promise<void> {
if (args.open) { if (args.open) {
// TODO: this is broken? // TODO: this is broken?
const url = `http://${args.host}:${args.port}` const url = `http://${args.host}:${args.port}`
console.log(`opening browser to ${url}`) console.log(`Opening ${url} in web browser...`)
const process = new Deno.Command('xdg-open', { await open(url)
args: [url],
}).spawn()
console.log(`opened browser to ${url}: ${await process.status}`)
} }
} }