Skip to content

Commit

Permalink
Merge pull request #77 from ptlthg/fix/catch-neu-repo-clone-error
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthGigi authored Jan 8, 2025
2 parents 0bf75ea + e465d7e commit ba10632
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/lib/server/helper/NotEnoughUpdates/parseNEURepository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { building, dev } from "$app/environment";
import type { NEUItem } from "$types/processed/NotEnoughUpdates/NotEnoughUpdates";
import fs from "node:fs";
import simpleGit from "simple-git";
import { GitError, simpleGit } from "simple-git";
import { NBTParser } from "./NBTParser";
import { formatBestiaryConstants } from "./parsers/bestiary";
import { updateNotEnoughUpdatesRepository } from "./updateNEURepository";
Expand All @@ -27,7 +27,15 @@ export async function intializeNEURepository() {

if (!dev || !fs.existsSync("NotEnoughUpdates-REPO/.git")) {
console.log(`[NOT-ENOUGH-UPDATES] Cloning NEU repository.`);
await simpleGit().clone("https://github.com/NotEnoughUpdates/NotEnoughUpdates-REPO", "NotEnoughUpdates-REPO");
try {
await simpleGit().clone("https://github.com/NotEnoughUpdates/NotEnoughUpdates-REPO", "NotEnoughUpdates-REPO");
} catch (error) {
if (error instanceof GitError && error.message.includes("already exists")) {
console.log("[NOT-ENOUGH-UPDATES] Repository already exists.");
} else {
console.error("[NOT-ENOUGH-UPDATES] Error cloning repository:", error);
}
}
}
}

Expand Down

0 comments on commit ba10632

Please sign in to comment.