( row: PreparedBatchRow, manifest: BatchManifest, options: RunBatchRenderOptions, )
| 309 | } |
| 310 | |
| 311 | async function renderBatchRow( |
| 312 | row: PreparedBatchRow, |
| 313 | manifest: BatchManifest, |
| 314 | options: RunBatchRenderOptions, |
| 315 | ): Promise<boolean> { |
| 316 | const manifestRow = manifest.rows[row.index]; |
| 317 | if (!manifestRow) { |
| 318 | throw new Error(`Batch manifest is missing row ${row.index}`); |
| 319 | } |
| 320 | |
| 321 | manifestRow.status = "running"; |
| 322 | manifestRow.startedAt = new Date().toISOString(); |
| 323 | writeManifest(manifest); |
| 324 | emitJsonEvent( |
| 325 | { type: "batch-row-start", index: row.index, outputPath: row.outputPath }, |
| 326 | options.json, |
| 327 | ); |
| 328 | |
| 329 | if (!options.quiet && !options.json) { |
| 330 | console.log(c.dim(`Batch row ${row.index}: ${row.outputPath}`)); |
| 331 | } |
| 332 | |
| 333 | try { |
| 334 | mkdirSync(dirname(row.outputPath), { recursive: true }); |
| 335 | const result = await options.renderOne(row); |
| 336 | manifestRow.status = "completed"; |
| 337 | manifestRow.durationMs = result.durationMs ?? null; |
| 338 | manifestRow.renderTimeMs = result.renderTimeMs; |
| 339 | manifestRow.completedAt = new Date().toISOString(); |
| 340 | writeManifest(manifest); |
| 341 | emitJsonEvent( |
| 342 | { |
| 343 | type: "batch-row-complete", |
| 344 | index: row.index, |
| 345 | outputPath: row.outputPath, |
| 346 | durationMs: manifestRow.durationMs, |
| 347 | renderTimeMs: manifestRow.renderTimeMs, |
| 348 | }, |
| 349 | options.json, |
| 350 | ); |
| 351 | return true; |
| 352 | } catch (error: unknown) { |
| 353 | manifestRow.status = "failed"; |
| 354 | manifestRow.error = errorMessage(error); |
| 355 | manifestRow.completedAt = new Date().toISOString(); |
| 356 | writeManifest(manifest); |
| 357 | emitJsonEvent( |
| 358 | { |
| 359 | type: "batch-row-error", |
| 360 | index: row.index, |
| 361 | outputPath: row.outputPath, |
| 362 | error: manifestRow.error, |
| 363 | }, |
| 364 | options.json, |
| 365 | ); |
| 366 | if (!options.quiet && !options.json) { |
| 367 | console.log(c.error(` Row ${row.index} failed: ${manifestRow.error}`)); |
| 368 | } |
no test coverage detected