()
| 73 | } |
| 74 | |
| 75 | async function loadEntries() { |
| 76 | const results = []; |
| 77 | const errors = []; |
| 78 | |
| 79 | for (const category of CATEGORIES) { |
| 80 | const categoryPath = path.join(__dirname, '../data', category); |
| 81 | let entries = []; |
| 82 | |
| 83 | try { |
| 84 | entries = await readYamlDir(categoryPath); |
| 85 | } catch (err) { |
| 86 | if (err.code === 'ENOENT') { |
| 87 | continue; |
| 88 | } |
| 89 | throw err; |
| 90 | } |
| 91 | |
| 92 | for (const entry of entries) { |
| 93 | const result = validateEntry(entry, entry._filePath || categoryPath); |
| 94 | if (!result.valid) { |
| 95 | errors.push(formatValidationErrors(result)); |
| 96 | continue; |
| 97 | } |
| 98 | |
| 99 | const mapped = mapEntry(entry, category); |
| 100 | if (mapped) { |
| 101 | results.push(stripUndefined(mapped)); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | return { results, errors }; |
| 107 | } |
| 108 | |
| 109 | async function main() { |
| 110 | const { outputPath, pretty } = parseArgs(process.argv.slice(2)); |
no test coverage detected