| 57 | ]; |
| 58 | |
| 59 | function whichBinary(name: string): string | undefined { |
| 60 | try { |
| 61 | const cmd = process.platform === "win32" ? `where ${name}` : `which ${name}`; |
| 62 | const output = execSync(cmd, { |
| 63 | encoding: "utf-8", |
| 64 | stdio: ["pipe", "pipe", "pipe"], |
| 65 | timeout: 5000, |
| 66 | }); |
| 67 | const first = output |
| 68 | .split(/\r?\n/) |
| 69 | .map((s) => s.trim()) |
| 70 | .find(Boolean); |
| 71 | return first || undefined; |
| 72 | } catch { |
| 73 | return undefined; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | function findFromEnv(): BrowserResult | undefined { |
| 78 | const envPath = process.env["HYPERFRAMES_BROWSER_PATH"]; |