Skip to content

Commit

Permalink
Convert .parse to .safeParse to alleviate zod parsing errors with…
Browse files Browse the repository at this point in the history
… manifests that don't matter
  • Loading branch information
toebeann committed Dec 7, 2024
1 parent 3c67e53 commit 257ceb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "gib",
"version": "0.7.3",
"version": "0.7.4",
"description": "A TUI application for automating the installation of BepInEx",
"license": "ISC",
"author": "Tobey Blaber",
Expand Down
18 changes: 15 additions & 3 deletions src/launchers/steam/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ export async function* getApps() {
});
for await (const manifestPath of glob) {
try {
const manifest = appManifestSchema.parse(
const parser = appManifestSchema.safeParse(
parse(await readFile(manifestPath, { encoding: "utf-8" })),
);

if (!parser.success) continue;

const { data: manifest } = parser;

yield {
launcher,
manifest,
Expand Down Expand Up @@ -99,10 +103,14 @@ export const getAppById = async (id: string) => {
`appmanifest_${id}.acf`,
);

const manifest = appManifestSchema.parse(
const parser = appManifestSchema.safeParse(
parse(await readFile(manifestPath, { encoding: "utf-8" })),
);

if (!parser.success) return;

const { data: manifest } = parser;

return {
launcher,
manifest,
Expand Down Expand Up @@ -144,10 +152,14 @@ export async function* getAppsByPath(path: string) {
cwd: join(folderPath, "steamapps"),
});
for await (const manifestPath of glob) {
const manifest = appManifestSchema.parse(
const parser = appManifestSchema.safeParse(
parse(await readFile(manifestPath, "utf8")),
);

if (!parser.success) continue;

const { data: manifest } = parser;

if (basename(resolved) === manifest.appState.installdir) {
yield {
launcher,
Expand Down

0 comments on commit 257ceb6

Please sign in to comment.