(commands, ghPath)
| 83 | } |
| 84 | |
| 85 | function fetchWithGh(commands, ghPath) { |
| 86 | const batches = []; |
| 87 | for (const [_command, args] of commands) { |
| 88 | const result = spawnSync(ghPath, args, { |
| 89 | encoding: 'utf8', |
| 90 | stdio: ['pipe', 'pipe', 'pipe'], |
| 91 | maxBuffer: 16 * 1024 * 1024, |
| 92 | shell: process.platform === 'win32', |
| 93 | }); |
| 94 | if (result.status !== 0) { |
| 95 | const detail = (result.stderr || result.stdout || result.error?.message || '').trim(); |
| 96 | throw new Error(`gh api failed for ${args[1]}: ${detail}`); |
| 97 | } |
| 98 | const source = sourceForArgs(args); |
| 99 | batches.push(...parseJsonValues(result.stdout).map((item) => ({ source, ...item }))); |
| 100 | } |
| 101 | return batches; |
| 102 | } |
| 103 | |
| 104 | if (process.argv.includes('--help')) { |
| 105 | console.log('Usage: node scripts/codex-review-fetch.js --repo owner/name --pr N [--write]'); |
no test coverage detected