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

Function prepareBatchRender

packages/cli/src/commands/batchRender.ts:231–270  ·  view source on GitHub ↗
(options: PrepareBatchRenderOptions)

Source from the content-addressed store, hash-verified

229}
230
231export function prepareBatchRender(options: PrepareBatchRenderOptions): PreparedBatchRender {
232 const batchPath = resolve(options.batchPath);
233 const read = options.readFile ?? ((path: string) => readFileSync(path, "utf8"));
234 let raw: string;
235 try {
236 raw = read(batchPath);
237 } catch (error: unknown) {
238 throw new BatchRenderInputError(
239 "Could not read --batch",
240 `${batchPath}: ${errorMessage(error)}`,
241 );
242 }
243
244 const variableRows = parseBatchRows(raw, batchPath);
245 const rows = variableRows.map((variables, index) => ({
246 index,
247 variables,
248 outputPath: resolve(resolveOutputTemplate(options.outputTemplate, variables, index)),
249 }));
250 const manifestPath = join(
251 commonOutputDirectory(rows.map((row) => row.outputPath)),
252 "manifest.json",
253 );
254 checkOutputCollisions(rows, manifestPath);
255
256 const variableIssueCount = validateBatchVariables(
257 variableRows,
258 options.indexPath,
259 options.strictVariables,
260 options.quiet,
261 options.json,
262 );
263
264 return {
265 batchPath,
266 manifestPath,
267 variableIssueCount,
268 rows,
269 };
270}
271
272function makeInitialManifest(prepared: PreparedBatchRender): BatchManifest {
273 return {

Callers 1

Calls 7

resolveFunction · 0.85
errorMessageFunction · 0.85
parseBatchRowsFunction · 0.85
resolveOutputTemplateFunction · 0.85
commonOutputDirectoryFunction · 0.85
checkOutputCollisionsFunction · 0.85
validateBatchVariablesFunction · 0.85

Tested by

no test coverage detected