Skip to content

Commit

Permalink
maybe fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckySoLucky committed Nov 26, 2024
1 parent 3a46a8c commit 9c7de5e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/lib/server/helper/NotEnoughUpdates/parseNEURepository.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import type { NEUItem } from "$types/processed/NotEnoughUpdates/NotEnoughUpdates";
import fs from "node:fs";
import { formatBestiaryConstants } from "./parsers/bestiary";
import { NBTParser } from "./NBTParser";
import { formatBestiaryConstants } from "./parsers/bestiary";

export const NEU_ITEMS = new Map<string, NEUItem>();
export const NEU_CONSTANTS = new Map();

export async function parseNEURepository() {
const timeNow = performance.now();
if (!fs.existsSync("src/lib/server/constants/NotEnoughUpdates-REPO/items")) {
throw new Error("Couldn't find the NEU items directory (src/lib/server/constants/NotEnoughUpdates-REPO/items). Make sure you have the NEU repository cloned in the correct location.");
const itemsPath = "src/lib/server/constants/NotEnoughUpdates-REPO/items";

if (!fs.existsSync(itemsPath)) {
throw new Error(`Couldn't find the NEU items directory (${itemsPath}). Make sure you have the NEU repository cloned in the correct location.`);
}

const items = fs.readdirSync("src/lib/server/constants/NotEnoughUpdates-REPO/items");
const items = fs.readdirSync(itemsPath);
for (const item of items) {
const itemData = JSON.parse(fs.readFileSync(`src/lib/server/constants/NotEnoughUpdates-REPO/items/${item}`, "utf8"));

itemData.nbttag = NBTParser.parse(itemData.nbttag);
const itemPath = `${itemsPath}/${item}`;
if (!fs.statSync(itemPath).isFile()) {
continue;
}

NEU_ITEMS.set(itemData.internalname, itemData);
try {
const itemData = JSON.parse(fs.readFileSync(itemPath, "utf8"));
itemData.nbttag = NBTParser.parse(itemData.nbttag);
NEU_ITEMS.set(itemData.internalname, itemData);
} catch (error) {
console.error(`Error processing item ${item}:`, error);
}
}

const constants = fs.readdirSync("src/lib/server/constants/NotEnoughUpdates-REPO/constants");
Expand Down

0 comments on commit 9c7de5e

Please sign in to comment.