(cmd, options = {})
| 20 | const verbose = args.values.verbose; |
| 21 | |
| 22 | async 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 | |
| 49 | async function getTscFromReadme() { |
| 50 | const readmeText = readline.createInterface({ |
no test coverage detected
searching dependent graphs…