(env: NodeJS.ProcessEnv = process.env, platform: string = process.platform)
| 18 | * headless cases so a server run or CI job doesn't try to spawn a GUI. |
| 19 | */ |
| 20 | export 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. */ |
| 33 | function openerFor(url: string, platform: string): { cmd: string; args: string[] } { |
no outgoing calls
no test coverage detected