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

Function runShim

__tests__/npm-shim.test.ts:71–81  ·  view source on GitHub ↗
(pkgDir: string, args: string[], env: Record<string, string>)

Source from the content-addressed store, hash-verified

69// Launch the shim with async spawn so the in-process HTTPS server can respond
70// while it runs (spawnSync would block this event loop and deadlock).
71function runShim(pkgDir: string, args: string[], env: Record<string, string>) {
72 return new Promise<{ status: number | null; stdout: string; stderr: string }>((resolve) => {
73 const child = spawn(process.execPath, [path.join(pkgDir, 'npm-shim.js'), ...args], {
74 env: { ...process.env, ...env },
75 });
76 let stdout = '', stderr = '';
77 child.stdout.on('data', (d) => { stdout += d.toString(); });
78 child.stderr.on('data', (d) => { stderr += d.toString(); });
79 child.on('close', (status) => resolve({ status, stdout, stderr }));
80 });
81}
82
83// Static source guard (all platforms): every child spawn in the shim must set
84// windowsHide, or a console (conhost) window flashes when the shim runs as a

Callers 1

npm-shim.test.tsFile · 0.85

Calls 3

onMethod · 0.65
resolveFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected