From af52afbad1d4f02bf233aadd46b48d280653e8cd Mon Sep 17 00:00:00 2001 From: Christopher Monsanto Date: Sun, 22 Jan 2023 11:05:51 -0500 Subject: [PATCH] ps sheet: allow reporting multiple errors --- ps-pokemon.sheet.mjs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ps-pokemon.sheet.mjs b/ps-pokemon.sheet.mjs index e51a9248..9575b3da 100644 --- a/ps-pokemon.sheet.mjs +++ b/ps-pokemon.sheet.mjs @@ -541,6 +541,8 @@ const BattlePokemonIconIndexesLeft = { const entries = []; +let errors = []; + // Need to figure out how to remove this readdir; tup doesn't like it for (const name of fs.readdirSync(spritesDir)) { const parsed = path.parse(name); @@ -568,7 +570,8 @@ for (const name of fs.readdirSync(spritesDir)) { if (entry) { index = entry.num; } else { - throw new Error(`can't find ${name}`) + errors.push(`can't find ${name}`); + continue; } } @@ -577,16 +580,23 @@ for (const name of fs.readdirSync(spritesDir)) { for (const [id, num] of Object.entries(BattlePokemonIconIndexes)) { if (num !== 'found') { - throw new Error(`didn't find ${id}`); + errors.push(`didn't find ${id}`); } } for (const [id, num] of Object.entries(BattlePokemonIconIndexesLeft)) { if (num !== 'found') { - throw new Error(`didn't find left ${id}`); + errors.push(`didn't find left ${id}`); } } +if (errors.length) { + for (let error of errors) { + console.error(error); + } + process.exit(1); +} + for (let i = 0; i < entries.length; i++) { if (entries[i] === undefined) entries[i] = null;