| 15 | const binPath = path.join(__dirname, 'bin', binName); |
| 16 | const executionPath = binPath; |
| 17 | const cacheReady = () => { |
| 18 | if (!fs.existsSync(binPath)) { |
| 19 | return false; |
| 20 | } |
| 21 | if (!isWindows) return true; |
| 22 | // A cached Windows binary that cannot report its own version is not usable. |
| 23 | const probe = spawnSync(binPath, ['--version'], { |
| 24 | stdio: 'ignore', |
| 25 | timeout: 15_000, |
| 26 | windowsHide: true, |
| 27 | }); |
| 28 | return !probe.error && probe.status === 0; |
| 29 | }; |
| 30 | |
| 31 | if (!cacheReady()) { |
| 32 | // Binary missing — try running the install script (handles --ignore-scripts case) |