Add initial pack definitions
This commit is contained in:
parent
5b9e808ea9
commit
8f206baf46
5 changed files with 146 additions and 1 deletions
36
scripts/buildCompendia.mjs
Normal file
36
scripts/buildCompendia.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { existsSync } from "fs";
|
||||
import { readFile } from "fs/promises";
|
||||
import { join } from "path";
|
||||
import { compilePack } from "@foundryvtt/foundryvtt-cli";
|
||||
import { pathToFileURL } from "url";
|
||||
|
||||
export async function buildCompendia() {
|
||||
const manifest = JSON.parse(await readFile(`./system.json`, `utf-8`));
|
||||
|
||||
if (!manifest.packs || manifest.packs.length === 0) {
|
||||
console.log(`No compendium packs defined`);
|
||||
process.exit(0);
|
||||
};
|
||||
console.log(`Packing compendia`);
|
||||
|
||||
for (const compendium of manifest.packs) {
|
||||
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(
|
||||
src,
|
||||
join(process.cwd(), compendium.path),
|
||||
{ recursive: true },
|
||||
);
|
||||
console.debug(`Finished packing compendium: ${compendium.name}`);
|
||||
};
|
||||
|
||||
console.log(`Finished packing all compendia`)
|
||||
};
|
||||
|
||||
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||
buildCompendia();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue