* Run `opencode `. If a `binary` path is given (an absolute path resolved * for a stock `~/.opencode/bin` install or a version-manager shim that is not on * PATH), call that exact path via execFile; otherwise fall back to a bare * `opencode` on PATH.
(args: string[], binary?: string | null)
| 7 | * `opencode` on PATH. |
| 8 | */ |
| 9 | function runOpenCode(args: string[], binary?: string | null): string | null { |
| 10 | try { |
| 11 | if (binary) { |
| 12 | return execFileSync(binary, args, { stdio: "pipe" }).toString().trim(); |
| 13 | } |
| 14 | return execSync(`opencode ${args.join(" ")}`, { stdio: "pipe" }) |
| 15 | .toString() |
| 16 | .trim(); |
| 17 | } catch { |
| 18 | return null; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | export function getOpenCodeVersion(binary?: string | null): string | null { |
| 23 | return runOpenCode(["--version"], binary); |
no outgoing calls
no test coverage detected