From 3da5d819579d02bcac8bc38a079e78fa409c99bc Mon Sep 17 00:00:00 2001 From: sbkaf <> Date: Mon, 8 Sep 2025 20:00:00 +0200 Subject: [PATCH] open the browser with -o, --open like in vite otherwise do nothing --- backend/instance.ts | 1 + backend/program.ts | 8 +++++++- backend/run.ts | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/instance.ts b/backend/instance.ts index b987cdb..e15f58a 100644 --- a/backend/instance.ts +++ b/backend/instance.ts @@ -14,6 +14,7 @@ import { env } from "process"; export type Options = { basePort: number; + open: boolean; csp: boolean; verbose: boolean; }; diff --git a/backend/program.ts b/backend/program.ts index 24288ac..9c6adf0 100644 --- a/backend/program.ts +++ b/backend/program.ts @@ -34,6 +34,7 @@ export function createProgram(inject: Inject): Command { parsePort, 7000, ) + .option("-o, --open", "automatically open webxdc-dev UI in the browser") .option("--no-csp", "run instances without CSP applied") .option( "-v, --verbose", @@ -46,7 +47,12 @@ export function createProgram(inject: Inject): Command { .action(async (location, options) => { await run( location, - { basePort: options.port, csp: options.csp, verbose: options.verbose }, + { + basePort: options.port, + open: options.open, + csp: options.csp, + verbose: options.verbose, + }, inject, ); }); diff --git a/backend/run.ts b/backend/run.ts index 9cdfd78..f1bbf1d 100644 --- a/backend/run.ts +++ b/backend/run.ts @@ -43,8 +43,7 @@ async function actualRun( instances.start(); - if (!env["CODESPACE_NAME"]) { - // do not auto open on gh codespace + if (options.open) { open("http://localhost:" + options.basePort); } }