(url: string)
| 13 | } |
| 14 | |
| 15 | export async function openBrowser(url: string): Promise<OpenBrowserResult> { |
| 16 | if (process.env["BROWSER"] === "none" || process.env["HF_NO_BROWSER"] === "1") { |
| 17 | printManualInstructions(url); |
| 18 | return { opened: false }; |
| 19 | } |
| 20 | try { |
| 21 | const open = (await import("open")).default; |
| 22 | await open(url); |
| 23 | return { opened: true }; |
| 24 | } catch (err) { |
| 25 | printManualInstructions(url, normalizeErrorMessage(err)); |
| 26 | return { opened: false }; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | function printManualInstructions(url: string, detail?: string): void { |
| 31 | if (detail) { |
no test coverage detected