(options?: EnsureBrowserOptions)
| 352 | * Resolution: env var -> cached download -> system Chrome -> auto-download. |
| 353 | */ |
| 354 | export async function ensureBrowser(options?: EnsureBrowserOptions): Promise<BrowserResult> { |
| 355 | const fromEnv = findFromEnv(); |
| 356 | if (fromEnv) return fromEnv; |
| 357 | |
| 358 | const fromCache = await findFromCache(); |
| 359 | if (fromCache.result) return fromCache.result; |
| 360 | if (fromCache.staleHyperframesCachePath) { |
| 361 | console.warn( |
| 362 | `[browser] Cached binary missing at ${fromCache.staleHyperframesCachePath} — re-downloading...`, |
| 363 | ); |
| 364 | return downloadBrowser(options); |
| 365 | } |
| 366 | |
| 367 | const fromSystem = findFromSystem(); |
| 368 | if (fromSystem) { |
| 369 | warnSystemFallbackOnce(fromSystem.executablePath); |
| 370 | return fromSystem; |
| 371 | } |
| 372 | |
| 373 | return downloadBrowser(options); |
| 374 | } |
| 375 | |
| 376 | async function downloadBrowser(options?: EnsureBrowserOptions): Promise<BrowserResult> { |
| 377 | if (isLinuxArm()) { |
no test coverage detected