Browser opens
This commit is contained in:
parent
bf2bd6ad54
commit
6b684bfd48
2 changed files with 21 additions and 4 deletions
12
deno.lock
12
deno.lock
|
@ -1,6 +1,14 @@
|
||||||
{
|
{
|
||||||
"version": "3",
|
"version": "3",
|
||||||
|
"redirects": {
|
||||||
|
"https://deno.land/x/is_docker/mod.ts": "https://deno.land/x/is_docker@v2.0.0/mod.ts",
|
||||||
|
"https://deno.land/x/open/index.ts": "https://deno.land/x/open@v0.0.6/index.ts"
|
||||||
|
},
|
||||||
"remote": {
|
"remote": {
|
||||||
|
"https://deno.land/std@0.106.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853",
|
||||||
|
"https://deno.land/std@0.106.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4",
|
||||||
|
"https://deno.land/std@0.106.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b",
|
||||||
|
"https://deno.land/std@0.106.0/path/posix.ts": "b81974c768d298f8dcd2c720229639b3803ca4a241fa9a355c762fa2bc5ef0c1",
|
||||||
"https://deno.land/std@0.221.0/assert/assert.ts": "bec068b2fccdd434c138a555b19a2c2393b71dfaada02b7d568a01541e67cdc5",
|
"https://deno.land/std@0.221.0/assert/assert.ts": "bec068b2fccdd434c138a555b19a2c2393b71dfaada02b7d568a01541e67cdc5",
|
||||||
"https://deno.land/std@0.221.0/assert/assertion_error.ts": "9f689a101ee586c4ce92f52fa7ddd362e86434ffdf1f848e45987dc7689976b8",
|
"https://deno.land/std@0.221.0/assert/assertion_error.ts": "9f689a101ee586c4ce92f52fa7ddd362e86434ffdf1f848e45987dc7689976b8",
|
||||||
"https://deno.land/std@0.221.0/console/_data.json": "cf2cc9d039a192b3adbfe64627167c7e6212704c888c25c769fc8f1709e1e1b8",
|
"https://deno.land/std@0.221.0/console/_data.json": "cf2cc9d039a192b3adbfe64627167c7e6212704c888c25c769fc8f1709e1e1b8",
|
||||||
|
@ -68,6 +76,10 @@
|
||||||
"https://deno.land/x/cliffy@v1.0.0-rc.4/table/deps.ts": "cbb896e8d7a6b5e3c2b9dda7d16638c202d9b46eb738c2dae1fa9480d8091486",
|
"https://deno.land/x/cliffy@v1.0.0-rc.4/table/deps.ts": "cbb896e8d7a6b5e3c2b9dda7d16638c202d9b46eb738c2dae1fa9480d8091486",
|
||||||
"https://deno.land/x/cliffy@v1.0.0-rc.4/table/row.ts": "79eb1468aafdd951e5963898cdafe0752d4ab4c519d5f847f3d8ecb8fe857d4f",
|
"https://deno.land/x/cliffy@v1.0.0-rc.4/table/row.ts": "79eb1468aafdd951e5963898cdafe0752d4ab4c519d5f847f3d8ecb8fe857d4f",
|
||||||
"https://deno.land/x/cliffy@v1.0.0-rc.4/table/table.ts": "298671e72e61f1ab18b42ae36643181993f79e29b39dc411fdc6ffd53aa04684",
|
"https://deno.land/x/cliffy@v1.0.0-rc.4/table/table.ts": "298671e72e61f1ab18b42ae36643181993f79e29b39dc411fdc6ffd53aa04684",
|
||||||
|
"https://deno.land/x/is_docker@v2.0.0/mod.ts": "4c8753346f4afbb6c251d7984a609aa84055559cf713fba828939a5d39c95cd0",
|
||||||
|
"https://deno.land/x/is_wsl@v1.1.0/mod.ts": "30996b09376652df7a4d495320e918154906ab94325745c1399e13e658dca5da",
|
||||||
|
"https://deno.land/x/open@v0.0.6/index.ts": "c7484a7bf2628236f33bbe354520e651811faf1a7cbc3c3f80958ce81b4c42ef",
|
||||||
|
"https://deno.land/x/opener@v1.0.1/mod.ts": "dd021a0327b29d8548c78881325dabe3079512e9647ae8b2050797875e70c87d",
|
||||||
"https://deno.land/x/zod@v3.23.8/ZodError.ts": "528da200fbe995157b9ae91498b103c4ef482217a5c086249507ac850bd78f52",
|
"https://deno.land/x/zod@v3.23.8/ZodError.ts": "528da200fbe995157b9ae91498b103c4ef482217a5c086249507ac850bd78f52",
|
||||||
"https://deno.land/x/zod@v3.23.8/errors.ts": "5285922d2be9700cc0c70c95e4858952b07ae193aa0224be3cbd5cd5567eabef",
|
"https://deno.land/x/zod@v3.23.8/errors.ts": "5285922d2be9700cc0c70c95e4858952b07ae193aa0224be3cbd5cd5567eabef",
|
||||||
"https://deno.land/x/zod@v3.23.8/external.ts": "a6cfbd61e9e097d5f42f8a7ed6f92f93f51ff927d29c9fbaec04f03cbce130fe",
|
"https://deno.land/x/zod@v3.23.8/external.ts": "a6cfbd61e9e097d5f42f8a7ed6f92f93f51ff927d29c9fbaec04f03cbce130fe",
|
||||||
|
|
13
mod.ts
13
mod.ts
|
@ -1,6 +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'
|
import { open } from 'https://deno.land/x/open@v0.0.6/index.ts'
|
||||||
|
|
||||||
const sockets: Set<WebSocket> = new Set([])
|
const sockets: Set<WebSocket> = new Set([])
|
||||||
|
|
||||||
|
@ -46,9 +46,14 @@ const command = new Command()
|
||||||
async function openBrowser(args: Args): Promise<void> {
|
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}`
|
try {
|
||||||
console.log(`Opening ${url} in web browser...`)
|
const url = `http://${args.host}:${args.port}`
|
||||||
await open(url)
|
console.log(`Opening ${url} in web browser...`)
|
||||||
|
// TODO: this won't work on NixOS for the time being I expect
|
||||||
|
await open(url)
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Failed to open browser: ${err}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue