MCPcopy Create free account
hub / github.com/cortexkit/magic-context / getPiVersion

Function getPiVersion

packages/cli/src/lib/pi-helpers.ts:31–49  ·  view source on GitHub ↗
(piPath: string)

Source from the content-addressed store, hash-verified

29}
30
31export 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
51function runPi(piPath: string, args: string[]): string | null {
52 try {

Callers 1

collectDiagnosticsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected