(pkgDir: string, args: string[], env: Record<string, string>)
| 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). |
| 71 | function 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 |
no test coverage detected