(options = {})
| 608 | } |
| 609 | |
| 610 | function spawnInstalledBinary(options = {}) { |
| 611 | if (!fs.existsSync(CONFIG.binaryPath)) { |
| 612 | try { |
| 613 | if (fs.existsSync(CONFIG.metadataPath)) fs.unlinkSync(CONFIG.metadataPath) |
| 614 | } catch { |
| 615 | // best effort |
| 616 | } |
| 617 | const error = new Error( |
| 618 | `downloaded binary is missing at ${CONFIG.binaryPath}`, |
| 619 | ) |
| 620 | error.code = 'BINARY_MISSING' |
| 621 | printSpawnFailure(error) |
| 622 | process.exit(1) |
| 623 | } |
| 624 | |
| 625 | const child = spawn(CONFIG.binaryPath, process.argv.slice(2), { |
| 626 | stdio: 'inherit', |
| 627 | ...options, |
| 628 | }) |
| 629 | |
| 630 | child.on('error', (err) => { |
| 631 | printSpawnFailure(err) |
| 632 | process.exit(1) |
| 633 | }) |
| 634 | |
| 635 | return child |
| 636 | } |
| 637 | |
| 638 | async function main() { |
| 639 | await ensureBinaryExists() |
no test coverage detected