(piPath: string)
| 29 | } |
| 30 | |
| 31 | export function getPiVersion(piPath: string): string | null { |
| 32 | // Pi >= 0.71.x writes `--version` output to stderr, not stdout. Use |
| 33 | // spawnSync (not execFileSync) so we get both streams back even on |
| 34 | // a clean exit. Prefer stdout when present so future Pi versions |
| 35 | // that switch back to stdout still work. |
| 36 | try { |
| 37 | const result = spawnSync(piPath, ["--version"], { |
| 38 | encoding: "utf-8", |
| 39 | timeout: 10_000, |
| 40 | }); |
| 41 | const stdout = result.stdout?.trim(); |
| 42 | if (stdout) return stdout; |
| 43 | const stderr = result.stderr?.trim(); |
| 44 | if (stderr) return stderr; |
| 45 | return null; |
| 46 | } catch { |
| 47 | return null; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | function runPi(piPath: string, args: string[]): string | null { |
| 52 | try { |
no outgoing calls
no test coverage detected