MCPcopy
hub / github.com/nodejs/corepack / runCli

Function runCli

tests/_runCli.ts:6–37  ·  view source on GitHub ↗
(cwd: PortablePath, argv: Array<string>, withCustomRegistry?: boolean)

Source from the content-addressed store, hash-verified

4import {pathToFileURL} from 'url';
5
6export async function runCli(cwd: PortablePath, argv: Array<string>, withCustomRegistry?: boolean): Promise<{exitCode: number | null, stdout: string, stderr: string}> {
7 const out: Array<Buffer> = [];
8 const err: Array<Buffer> = [];
9
10 return new Promise((resolve, reject) => {
11 const child = spawn(process.execPath, [`--no-warnings`, ...(withCustomRegistry ? [`--import`, pathToFileURL(path.join(__dirname, `_registryServer.mjs`)) as any as string] : [`-r`, require.resolve(`./recordRequests.js`)]), require.resolve(`../dist/corepack.js`), ...argv], {
12 cwd: npath.fromPortablePath(cwd),
13 env: process.env,
14 stdio: `pipe`,
15 });
16
17 child.stdout.on(`data`, chunk => {
18 out.push(chunk);
19 });
20
21 child.stderr.on(`data`, chunk => {
22 err.push(chunk);
23 });
24
25 child.on(`error`, error => {
26 reject(error);
27 });
28
29 child.on(`close`, exitCode => {
30 resolve({
31 exitCode,
32 stdout: Buffer.concat(out).toString(),
33 stderr: Buffer.concat(err).toString(),
34 });
35 });
36 });
37}

Callers 5

Use.test.tsFile · 0.90
Enable.test.tsFile · 0.90
Up.test.tsFile · 0.90
Disable.test.tsFile · 0.90
main.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…