Skip to content

Commit

Permalink
Delete folder property on extract if matching folder isn't found (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
stwlam committed Jul 29, 2023
1 parent 55348d0 commit 4d9f10a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions build/lib/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class PackExtractor {
const { packSources, folders } = await db.getEntries();

// Prepare subfolder data
if (folders.length) {
if (folders.length > 0) {
const getFolderPath = (folder: DBFolder, parts: string[] = []): string => {
if (parts.length > 3) {
throw PackError(
Expand Down Expand Up @@ -173,6 +173,8 @@ class PackExtractor {
const preparedSource = this.#convertLinks(source, packDirectory);
if ("items" in preparedSource && preparedSource.type === "npc" && !this.disablePresort) {
preparedSource.items = this.#sortDataItems(preparedSource);
} else if (!this.#folderPathMap.get(preparedSource.folder ?? "")) {
delete (preparedSource as { folder?: unknown }).folder;
}
const outData = this.#prettyPrintJSON(preparedSource);

Expand All @@ -181,7 +183,7 @@ class PackExtractor {
const outFileName = `${slug}.json`;

// Handle subfolders
const subfolder = preparedSource.folder ? this.#folderPathMap.get(preparedSource.folder) : null;
const subfolder = this.#folderPathMap.get(preparedSource.folder ?? "");
const outFolderPath = subfolder ? path.resolve(this.tempDataPath, subfolder) : outPath;
if (subfolder && !fs.existsSync(outFolderPath)) {
fs.mkdirSync(outFolderPath, { recursive: true });
Expand Down

0 comments on commit 4d9f10a

Please sign in to comment.