| 76 | } |
| 77 | |
| 78 | export function defaultProbes(filename: string): RemoveBinaryProbes { |
| 79 | return { |
| 80 | filename, |
| 81 | platform: process.platform, |
| 82 | cwd: process.cwd(), |
| 83 | env: process.env, |
| 84 | homedir: os.homedir(), |
| 85 | exists: fs.existsSync, |
| 86 | readlink: (p) => { |
| 87 | try { return fs.readlinkSync(p); } catch { return null; } |
| 88 | }, |
| 89 | capture: (cmd, args) => { |
| 90 | const res = spawnSync(cmd, args, { encoding: 'utf8', windowsHide: true, timeout: 30_000 }); |
| 91 | if (res.error || typeof res.status !== 'number') return null; |
| 92 | return { code: res.status, stdout: res.stdout ?? '' }; |
| 93 | }, |
| 94 | }; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Path math keyed on the TARGET platform (not the host) — same convention as |