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

Function canOpenBrowser

src/artifacts/open-browser.ts:20–30  ·  view source on GitHub ↗
(env: NodeJS.ProcessEnv = process.env, platform: string = process.platform)

Source from the content-addressed store, hash-verified

18 * headless cases so a server run or CI job doesn't try to spawn a GUI.
19 */
20export function canOpenBrowser(env: NodeJS.ProcessEnv = process.env, platform: string = process.platform): boolean {
21 // Explicit opt-out (any of the common spellings) always wins.
22 if (env.QODEX_NO_BROWSER || env.QODEX_NO_OPEN || env.NO_BROWSER) return false;
23 // CI systems have no human at a screen.
24 if (env.CI) return false;
25 // On Linux/BSD a GUI needs an X11 or Wayland display; without one, opening fails.
26 if (platform === 'linux' || platform === 'freebsd' || platform === 'openbsd') {
27 if (!env.DISPLAY && !env.WAYLAND_DISPLAY) return false;
28 }
29 return true;
30}
31
32/** The platform-appropriate opener command + args for a URL. */
33function openerFor(url: string, platform: string): { cmd: string; args: string[] } {

Callers 2

openUrlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected