MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / runCli

Function runCli

__tests__/cli-ui-command.test.ts:36–48  ·  view source on GitHub ↗

Run the CLI to completion, capturing stdout+stderr and the exit code.

(args: string[], env: Record<string, string> = {})

Source from the content-addressed store, hash-verified

34
35/** Run the CLI to completion, capturing stdout+stderr and the exit code. */
36function runCli(args: string[], env: Record<string, string> = {}): { code: number; output: string } {
37 try {
38 const output = execFileSync(process.execPath, [BIN, ...args], {
39 encoding: 'utf-8',
40 env: { ...BASE_ENV, ...env },
41 stdio: ['ignore', 'pipe', 'pipe'],
42 });
43 return { code: 0, output };
44 } catch (err) {
45 const e = err as { status?: number; stdout?: string; stderr?: string };
46 return { code: e.status ?? 1, output: `${e.stdout ?? ''}${e.stderr ?? ''}` };
47 }
48}
49
50/** GET a path from a running viewer, with a valid loopback Host. */
51function get(port: number, requestPath: string): Promise<{ status: number; body: string }> {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected