MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseBatchFile

Function parseBatchFile

packages/cli/src/commands/cloudrun.ts:695–722  ·  view source on GitHub ↗

Parse a JSONL batch file into entries, exiting with a clear error on a bad line.

(path: string)

Source from the content-addressed store, hash-verified

693
694/** Parse a JSONL batch file into entries, exiting with a clear error on a bad line. */
695function parseBatchFile(path: string): BatchEntry[] {
696 const lines = readFileSync(path, "utf8").split(/\r?\n/);
697 const entries: BatchEntry[] = [];
698 // fallow-ignore-next-line complexity
699 lines.forEach((line, idx) => {
700 const trimmed = line.trim();
701 if (!trimmed) return;
702 let parsed: unknown;
703 try {
704 parsed = JSON.parse(trimmed);
705 } catch {
706 console.error(`[cloudrun render-batch] line ${idx + 1}: not valid JSON`);
707 process.exit(1);
708 }
709 if (
710 !parsed ||
711 typeof parsed !== "object" ||
712 typeof (parsed as BatchEntry).outputKey !== "string"
713 ) {
714 console.error(
715 `[cloudrun render-batch] line ${idx + 1}: must be an object with a string "outputKey"`,
716 );
717 process.exit(1);
718 }
719 entries.push(parsed as BatchEntry);
720 });
721 return entries;
722}
723
724// ── destroy ──────────────────────────────────────────────────────────────
725

Callers 1

runRenderBatchFunction · 0.70

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected