(command, commandArgs, { label } = {})
| 100 | } |
| 101 | |
| 102 | function runCommand(command, commandArgs, { label } = {}) { |
| 103 | return new Promise((resolve, reject) => { |
| 104 | const child = spawn(command, commandArgs, { |
| 105 | stdio: ['ignore', 'pipe', 'pipe'], |
| 106 | shell: false, |
| 107 | }) |
| 108 | |
| 109 | const stdoutCleanup = pipeChildOutput(child.stdout, `[${label}]`) |
| 110 | const stderrCleanup = pipeChildOutput(child.stderr, `[${label}][stderr]`) |
| 111 | |
| 112 | child.on('error', (error) => { |
| 113 | stdoutCleanup() |
| 114 | stderrCleanup() |
| 115 | reject(error) |
| 116 | }) |
| 117 | |
| 118 | child.on('exit', (code, signal) => { |
| 119 | stdoutCleanup() |
| 120 | stderrCleanup() |
| 121 | |
| 122 | if (code === 0) { |
| 123 | resolve() |
| 124 | return |
| 125 | } |
| 126 | |
| 127 | reject( |
| 128 | new Error( |
| 129 | signal |
| 130 | ? `${command} ${commandArgs.join(' ')} exited with signal ${signal}` |
| 131 | : `${command} ${commandArgs.join(' ')} exited with code ${code}`, |
| 132 | ), |
| 133 | ) |
| 134 | }) |
| 135 | }) |
| 136 | } |
| 137 | |
| 138 | function buildRunTasks(totalRuns) { |
| 139 | return Array.from({ length: totalRuns }, (_, index) => ({ |
no test coverage detected