MCPcopy Index your code
hub / github.com/nodejs/node / runShellCommand

Function runShellCommand

tools/find-inactive-tsc.mjs:22–47  ·  view source on GitHub ↗
(cmd, options = {})

Source from the content-addressed store, hash-verified

20const verbose = args.values.verbose;
21
22async function runShellCommand(cmd, options = {}) {
23 const childProcess = cp.spawn('/bin/sh', ['-c', cmd], {
24 cwd: options.cwd ?? new URL('..', import.meta.url),
25 encoding: 'utf8',
26 stdio: ['inherit', 'pipe', 'inherit'],
27 });
28 const lines = readline.createInterface({
29 input: childProcess.stdout,
30 });
31 const errorHandler = new Promise(
32 (_, reject) => childProcess.on('error', reject),
33 );
34 let returnValue = options.returnAsArray ? [] : '';
35 await Promise.race([errorHandler, Promise.resolve()]);
36 // If no mapFn, return the value. If there is a mapFn, use it to make a Set to
37 // return.
38 for await (const line of lines) {
39 await Promise.race([errorHandler, Promise.resolve()]);
40 if (options.returnAsArray) {
41 returnValue.push(line);
42 } else {
43 returnValue += line;
44 }
45 }
46 return Promise.race([errorHandler, Promise.resolve(returnValue)]);
47}
48
49async function getTscFromReadme() {
50 const readmeText = readline.createInterface({

Callers 1

Calls 3

onMethod · 0.45
resolveMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…