mirror of
https://github.com/Kornstalx/5etools-mirror-2.github.io.git
synced 2025-10-28 20:45:35 -05:00
32 lines
854 B
JavaScript
32 lines
854 B
JavaScript
import "../js/parser.js";
|
|
import "../js/utils.js";
|
|
import * as ut from "../node/util.js";
|
|
|
|
async function main () {
|
|
console.log(`##### Validating adventure/book contents #####`);
|
|
|
|
const errors = [];
|
|
|
|
[
|
|
{filename: "adventures.json", prop: "adventure", dir: "adventure"},
|
|
{filename: "books.json", prop: "book", dir: "book"},
|
|
].flatMap(({filename, prop, dir}) => ut.readJson(`./data/${filename}`)[prop]
|
|
.map(({id, contents}) => ({filename: `./data/${dir}/${dir}-${id.toLowerCase()}.json`, contents})))
|
|
.forEach(({filename, contents}) => {
|
|
const json = ut.readJson(filename);
|
|
|
|
if (json.data.length === contents.length) return;
|
|
|
|
errors.push(`Contents length did not match data length in "${filename}"`);
|
|
});
|
|
|
|
if (errors.length) {
|
|
errors.forEach(err => console.error(err));
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
export default main();
|