Tofu/scripts/import-recipes/cli/formatImportSummary.js
2026-09-18 01:41:02 +02:00

10 lines
586 B
JavaScript

// The last thing printed: how many recipes made it, and every file that did not,
// with its reason. A failure is never swallowed - it is listed here even when
// the rest of the run went fine.
export function formatImportSummary({ importedCount, failures }) {
const recipes = importedCount === 1 ? 'recipe' : 'recipes'
const head = `${importedCount} ${recipes} imported, ${failures.length} failed.`
if (failures.length === 0) return head
const lines = failures.map(({ fileName, reason }) => ` ${fileName} - ${reason}`)
return [head, '', 'Failures:', ...lines].join('\n')
}