(call: GhCall)
| 13 | } |
| 14 | |
| 15 | export function jsonOutput(call: GhCall): Array<{ at: number; value: unknown }> { |
| 16 | const chunks = call.output.filter(chunk => chunk.stream === "stdout"); |
| 17 | const whole = json(chunks.map(chunk => chunk.text).join("")); |
| 18 | if (whole !== undefined && chunks.length) return [{ at: chunks.at(-1)!.at, value: whole }]; |
| 19 | const values: Array<{ at: number; value: unknown }> = []; |
| 20 | let pending = ""; |
| 21 | for (const chunk of chunks) { |
| 22 | pending += chunk.text; |
| 23 | let newline: number; |
| 24 | while ((newline = pending.indexOf("\n")) >= 0) { |
| 25 | const value = json(pending.slice(0, newline)); |
| 26 | if (value !== undefined) values.push({ at: chunk.at, value }); |
| 27 | pending = pending.slice(newline + 1); |
| 28 | } |
| 29 | } |
| 30 | if (pending.trim() && chunks.length) { |
| 31 | const value = json(pending); |
| 32 | if (value !== undefined) values.push({ at: chunks.at(-1)!.at, value }); |
| 33 | } |
| 34 | return values; |
| 35 | } |
| 36 | |
| 37 | function containsReview(value: unknown, reviewId: number, expected?: Record<string, unknown>): boolean { |
| 38 | if (Array.isArray(value)) return value.some(item => containsReview(item, reviewId, expected)); |
no test coverage detected