| 203 | let settled = false; |
| 204 | |
| 205 | const fail = (error: Error) => { |
| 206 | if (settled) return; |
| 207 | settled = true; |
| 208 | reject(error); |
| 209 | }; |
| 210 | const capture = (chunk: Buffer, keep: boolean) => { |
| 211 | outputBytes += chunk.length; |
| 212 | if (outputBytes > 10 * 1024 * 1024) { |
| 213 | child.kill(); |
| 214 | fail( |
| 215 | new Error( |
| 216 | `pnpm ${commandArgs.slice(0, 3).join(' ')} failed; provider output exceeded 10 MiB.` |
| 217 | ) |
| 218 | ); |
| 219 | return; |
| 220 | } |
| 221 | if (keep) stdout.push(chunk); |
| 222 | else stderr.push(chunk); |
| 223 | }; |
| 224 | |
| 225 | child.stdout.on('data', chunk => capture(Buffer.from(chunk), true)); |
| 226 | child.stderr.on('data', chunk => capture(Buffer.from(chunk), false)); |
| 227 | child.once('error', error => { |
| 228 | if (errorCode(error) === 'ENOENT') { |
| 229 | const message = missingCommandMessage('pnpm', commandArgs); |