(command: string, args: string[])
| 73 | } |
| 74 | |
| 75 | function checkCommand(command: string, args: string[]): RuntimeAppReadinessItem { |
| 76 | const result = spawnSync(command, args, { |
| 77 | env: process.env, |
| 78 | encoding: "utf8", |
| 79 | timeout: 5_000, |
| 80 | }); |
| 81 | if (result.error) { |
| 82 | return { available: false, error: result.error.message }; |
| 83 | } |
| 84 | if (result.status !== 0) { |
| 85 | return { |
| 86 | available: false, |
| 87 | error: tailAndRedact(`${result.stderr || result.stdout || `${command} exited with code ${result.status}`}`), |
| 88 | }; |
| 89 | } |
| 90 | const version = `${result.stdout ?? ""}\n${result.stderr ?? ""}`.trim().split(/\r?\n/)[0]?.trim(); |
| 91 | return { |
| 92 | available: true, |
| 93 | version: version || undefined, |
| 94 | }; |
| 95 | } |
| 96 | |
| 97 | function execCommand(command: RuntimeAppCommandPlanItem): Promise<{ stdout: string; stderr: string }> { |
| 98 | return new Promise((resolve, reject) => { |
no test coverage detected