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

Function cli

__tests__/cli-line-drift.test.ts:38–50  ·  view source on GitHub ↗

Run the built CLI in-process (no relaunch), recording which dist files it loaded.

(args: string[])

Source from the content-addressed store, hash-verified

36
37 /** Run the built CLI in-process (no relaunch), recording which dist files it loaded. */
38 function cli(args: string[]): { status: number | null; stdout: string; stderr: string; loaded: string[] } {
39 const r = spawnSync(process.execPath, [...WASM_RUNTIME_FLAGS, '--require', hook, BIN, ...args, '-p', dir], {
40 encoding: 'utf-8',
41 env: { ...process.env, CODEGRAPH_NO_DAEMON: '1', CODEGRAPH_WASM_RELAUNCHED: '1', NO_COLOR: '1', DO_NOT_TRACK: '1', CODEGRAPH_TELEMETRY: '0' },
42 timeout: 60_000,
43 });
44 const loaded = (JSON.parse(fs.readFileSync(loadedList, 'utf-8')) as string[])
45 .filter((f) => f.startsWith(DIST))
46 .map((f) => path.relative(DIST, f).split(path.sep).join('/'));
47 // Node's own experimental-SQLite notice isn't ours to assert on.
48 const stderr = r.stderr.split(/\r?\n/).filter((line) => !/ExperimentalWarning|--trace-warnings/.test(line)).join('\n');
49 return { status: r.status, stdout: r.stdout, stderr, loaded };
50 }
51
52 beforeEach(async () => {
53 root = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-line-drift-'));

Callers 1

Calls 3

mapMethod · 0.80
parseMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected