(
args: string[],
options: { cwd?: string; env?: NodeJS.ProcessEnv } = {},
)
| 62 | } |
| 63 | |
| 64 | function runEntrypointAsync( |
| 65 | args: string[], |
| 66 | options: { cwd?: string; env?: NodeJS.ProcessEnv } = {}, |
| 67 | ): Promise<{ stdout: string; stderr: string; exitCode: number }> { |
| 68 | return new Promise((resolve, reject) => { |
| 69 | const child = spawn('node', [ENTRYPOINT_PATH, ...args], { |
| 70 | cwd: options.cwd || ROOT_DIR, |
| 71 | env: { ...process.env, ...options.env, NO_COLOR: '1' }, |
| 72 | }); |
| 73 | |
| 74 | let stdout = ''; |
| 75 | let stderr = ''; |
| 76 | const timeoutId = setTimeout(() => { |
| 77 | child.kill('SIGTERM'); |
| 78 | reject(new Error(`CLI entrypoint timed out for: ${args.join(' ')}`)); |
| 79 | }, 30000); |
| 80 | |
| 81 | child.stdout.setEncoding('utf8'); |
| 82 | child.stdout.on('data', (chunk: string) => { |
| 83 | stdout += chunk; |
| 84 | }); |
| 85 | child.stderr.setEncoding('utf8'); |
| 86 | child.stderr.on('data', (chunk: string) => { |
| 87 | stderr += chunk; |
| 88 | }); |
| 89 | child.once('error', (error) => { |
| 90 | clearTimeout(timeoutId); |
| 91 | reject(error); |
| 92 | }); |
| 93 | child.once('close', (code) => { |
| 94 | clearTimeout(timeoutId); |
| 95 | resolve({ |
| 96 | stdout, |
| 97 | stderr, |
| 98 | exitCode: code ?? 1, |
| 99 | }); |
| 100 | }); |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | function runGit(args: string[], cwd: string): void { |
| 105 | const result = spawnSync('git', args, { |
no test coverage detected
searching dependent graphs…