| 140 | } |
| 141 | |
| 142 | function traceChunks( |
| 143 | args: Array<string>, |
| 144 | paths: string, |
| 145 | chunks: Array<string>, |
| 146 | cwd?: string |
| 147 | ) { |
| 148 | const turboTracingProcess = spawn('node-file-trace', [...args, ...chunks], { |
| 149 | stdio: 'pipe', |
| 150 | env: { |
| 151 | ...process.env, |
| 152 | PATH: paths, |
| 153 | RUST_BACKTRACE: '1', |
| 154 | }, |
| 155 | cwd, |
| 156 | }) |
| 157 | return new Promise<void>((resolve, reject) => { |
| 158 | turboTracingProcess.on('error', (err) => { |
| 159 | console.error(err) |
| 160 | }) |
| 161 | turboTracingProcess.stdout.on('data', (chunk: string | Uint8Array) => { |
| 162 | process.stdout.write(chunk) |
| 163 | }) |
| 164 | turboTracingProcess.stderr.on('data', (chunk: string | Uint8Array) => { |
| 165 | process.stderr.write(chunk) |
| 166 | }) |
| 167 | turboTracingProcess.once('exit', (code) => { |
| 168 | if (!code) { |
| 169 | resolve() |
| 170 | } else { |
| 171 | reject(code) |
| 172 | } |
| 173 | }) |
| 174 | }) |
| 175 | } |