Prevent erroring when the compendium doesn't have anything

This commit is contained in:
Oliver-Akins 2024-02-13 21:14:54 -07:00
parent 411ddca927
commit 8971f25b9d

View file

@ -1,3 +1,4 @@
import { existsSync } from "fs";
import { readFile } from "fs/promises"; import { readFile } from "fs/promises";
import { join } from "path"; import { join } from "path";
import { compilePack } from "@foundryvtt/foundryvtt-cli"; import { compilePack } from "@foundryvtt/foundryvtt-cli";
@ -12,8 +13,13 @@ async function main() {
for (const compendium of system.packs) { for (const compendium of system.packs) {
console.debug(`Packing ${compendium.label} (${compendium.name})`); console.debug(`Packing ${compendium.label} (${compendium.name})`);
let src = join(process.cwd(), compendium.path, `_source`);
if (!existsSync(src)) {
console.warn(`${compendium.path} doesn't exist, skipping.`)
continue;
};
await compilePack( await compilePack(
join(process.cwd(), compendium.path, `_source`), src,
join(process.cwd(), compendium.path), join(process.cwd(), compendium.path),
{ recursive: true }, { recursive: true },
); );