mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Adding Prettier
* Added prettier with automatic useage on pre-commit to avoid style breakage * Ran Prettier on the project
This commit is contained in:
parent
820c2df1f4
commit
b24cdcc9ed
136 changed files with 13929 additions and 12206 deletions
|
|
@ -1,16 +1,12 @@
|
|||
import { compilePack } from "@foundryvtt/foundryvtt-cli";
|
||||
import { promises as fs } from "fs";
|
||||
import { compilePack } from '@foundryvtt/foundryvtt-cli';
|
||||
import { promises as fs } from 'fs';
|
||||
|
||||
const MODULE_ID = process.cwd();
|
||||
const yaml = false;
|
||||
|
||||
const packs = await fs.readdir("./src/packs");
|
||||
const packs = await fs.readdir('./src/packs');
|
||||
for (const pack of packs) {
|
||||
if (pack === ".gitattributes") continue;
|
||||
console.log("Packing " + pack);
|
||||
await compilePack(
|
||||
`${MODULE_ID}/src/packs/${pack}`,
|
||||
`${MODULE_ID}/packs/${pack}`,
|
||||
{ yaml },
|
||||
);
|
||||
if (pack === '.gitattributes') continue;
|
||||
console.log('Packing ' + pack);
|
||||
await compilePack(`${MODULE_ID}/src/packs/${pack}`, `${MODULE_ID}/packs/${pack}`, { yaml });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,36 @@
|
|||
import { extractPack } from "@foundryvtt/foundryvtt-cli";
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import { extractPack } from '@foundryvtt/foundryvtt-cli';
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const MODULE_ID = process.cwd();
|
||||
const yaml = false;
|
||||
|
||||
const packs = await fs.readdir("./packs");
|
||||
const packs = await fs.readdir('./packs');
|
||||
for (const pack of packs) {
|
||||
if (pack === ".gitattributes") continue;
|
||||
console.log("Unpacking " + pack);
|
||||
const directory = `./src/packs/${pack}`;
|
||||
try {
|
||||
for (const file of await fs.readdir(directory)) {
|
||||
await fs.unlink(path.join(directory, file));
|
||||
if (pack === '.gitattributes') continue;
|
||||
console.log('Unpacking ' + pack);
|
||||
const directory = `./src/packs/${pack}`;
|
||||
try {
|
||||
for (const file of await fs.readdir(directory)) {
|
||||
await fs.unlink(path.join(directory, file));
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') console.log('No files inside of ' + pack);
|
||||
else console.log(error);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.code === "ENOENT") console.log("No files inside of " + pack);
|
||||
else console.log(error);
|
||||
}
|
||||
await extractPack(
|
||||
`${MODULE_ID}/packs/${pack}`,
|
||||
`${MODULE_ID}/src/packs/${pack}`,
|
||||
{
|
||||
yaml,
|
||||
transformName,
|
||||
},
|
||||
);
|
||||
await extractPack(`${MODULE_ID}/packs/${pack}`, `${MODULE_ID}/src/packs/${pack}`, {
|
||||
yaml,
|
||||
transformName
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Prefaces the document with its type
|
||||
* @param {object} doc - The document data
|
||||
*/
|
||||
function transformName(doc) {
|
||||
const safeFileName = doc.name.replace(/[^a-zA-Z0-9А-я]/g, "_");
|
||||
const type = doc._key.split("!")[1];
|
||||
const prefix = ["actors", "items"].includes(type) ? doc.type : type;
|
||||
const safeFileName = doc.name.replace(/[^a-zA-Z0-9А-я]/g, '_');
|
||||
const type = doc._key.split('!')[1];
|
||||
const prefix = ['actors', 'items'].includes(type) ? doc.type : type;
|
||||
|
||||
return `${doc.name ? `${prefix}_${safeFileName}_${doc._id}` : doc._id}.${
|
||||
yaml ? "yml" : "json"
|
||||
}`;
|
||||
return `${doc.name ? `${prefix}_${safeFileName}_${doc._id}` : doc._id}.${yaml ? 'yml' : 'json'}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue