Check if a binary is on PATH.
(cmd: string)
| 90 | |
| 91 | /** Check if a binary is on PATH. */ |
| 92 | async function which(cmd: string): Promise<string | null> { |
| 93 | return new Promise((resolve) => { |
| 94 | const p = spawn('which', [cmd]); |
| 95 | let out = ''; |
| 96 | p.stdout.on('data', (d) => { out += d.toString(); }); |
| 97 | p.on('exit', (code) => { |
| 98 | resolve(code === 0 ? out.trim() : null); |
| 99 | }); |
| 100 | p.on('error', () => resolve(null)); |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | /** Build a macOS sandbox profile that restricts writes to tempDir and optionally denies network. */ |
| 105 | function macosSandboxProfile(tempDir: string, allowNetwork: boolean): string { |