MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / openUrl

Function openUrl

src/artifacts/open-browser.ts:45–64  ·  view source on GitHub ↗
(
  url: string,
  opts: { env?: NodeJS.ProcessEnv; platform?: string } = {},
)

Source from the content-addressed store, hash-verified

43 * to spawn. Detached + unref'd so it never keeps the QodeX process alive.
44 */
45export async function openUrl(
46 url: string,
47 opts: { env?: NodeJS.ProcessEnv; platform?: string } = {},
48): Promise<boolean> {
49 const env = opts.env ?? process.env;
50 const platform = opts.platform ?? process.platform;
51 if (!canOpenBrowser(env, platform)) return false;
52 const { cmd, args } = openerFor(url, platform);
53 try {
54 const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
55 let ok = true;
56 child.on('error', () => { ok = false; }); // ENOENT (opener missing) etc. — swallow
57 child.unref();
58 // Give a spawn error a tick to surface before we report success.
59 await new Promise(r => setTimeout(r, 0));
60 return ok;
61 } catch {
62 return false;
63 }
64}

Callers 5

executeMethod · 0.85
runDashboardFunction · 0.85
writeStaticDashboardFunction · 0.85
runMaintainDemoFunction · 0.85

Calls 2

canOpenBrowserFunction · 0.85
openerForFunction · 0.85

Tested by

no test coverage detected