(name, records, outDirectory)
| 5 | import validateRecords from './validate-records.js' |
| 6 | |
| 7 | export async function writeIndexRecords(name, records, outDirectory) { |
| 8 | validateRecords(name, records) |
| 9 | |
| 10 | const recordsObject = Object.fromEntries(records.map((record) => [record.objectID, record])) |
| 11 | const content = JSON.stringify(recordsObject, undefined, 0) |
| 12 | |
| 13 | const filePath = path.join(outDirectory, `${name}-records.json`) |
| 14 | await fs.writeFile(filePath, content) |
| 15 | |
| 16 | return filePath |
| 17 | } |
no test coverage detected