(url: string, platform: NodeJS.Platform = process.platform)
| 62 | * @returns `true` if a launch was attempted. |
| 63 | */ |
| 64 | export function openBrowser(url: string, platform: NodeJS.Platform = process.platform): boolean { |
| 65 | const open = browserOpenCommand(url, platform, process.env[BROWSER_ENV]); |
| 66 | if (!open) return false; |
| 67 | try { |
| 68 | const child = spawn(open.command, open.args, { |
| 69 | detached: true, |
| 70 | stdio: 'ignore', |
| 71 | // `start` is a shell builtin reached through `cmd /c`, so no shell here. |
| 72 | shell: false, |
| 73 | }); |
| 74 | child.on('error', () => { |
| 75 | /* no opener installed — the printed URL is the fallback */ |
| 76 | }); |
| 77 | child.unref(); |
| 78 | return true; |
| 79 | } catch { |
| 80 | return false; |
| 81 | } |
| 82 | } |
no test coverage detected