Skip to content

Commit 257ceb6

Browse files
committed
Convert .parse to .safeParse to alleviate zod parsing errors with manifests that don't matter
1 parent 3c67e53 commit 257ceb6

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "gib",
4-
"version": "0.7.3",
4+
"version": "0.7.4",
55
"description": "A TUI application for automating the installation of BepInEx",
66
"license": "ISC",
77
"author": "Tobey Blaber",

src/launchers/steam/app.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ export async function* getApps() {
5959
});
6060
for await (const manifestPath of glob) {
6161
try {
62-
const manifest = appManifestSchema.parse(
62+
const parser = appManifestSchema.safeParse(
6363
parse(await readFile(manifestPath, { encoding: "utf-8" })),
6464
);
6565

66+
if (!parser.success) continue;
67+
68+
const { data: manifest } = parser;
69+
6670
yield {
6771
launcher,
6872
manifest,
@@ -99,10 +103,14 @@ export const getAppById = async (id: string) => {
99103
`appmanifest_${id}.acf`,
100104
);
101105

102-
const manifest = appManifestSchema.parse(
106+
const parser = appManifestSchema.safeParse(
103107
parse(await readFile(manifestPath, { encoding: "utf-8" })),
104108
);
105109

110+
if (!parser.success) return;
111+
112+
const { data: manifest } = parser;
113+
106114
return {
107115
launcher,
108116
manifest,
@@ -144,10 +152,14 @@ export async function* getAppsByPath(path: string) {
144152
cwd: join(folderPath, "steamapps"),
145153
});
146154
for await (const manifestPath of glob) {
147-
const manifest = appManifestSchema.parse(
155+
const parser = appManifestSchema.safeParse(
148156
parse(await readFile(manifestPath, "utf8")),
149157
);
150158

159+
if (!parser.success) continue;
160+
161+
const { data: manifest } = parser;
162+
151163
if (basename(resolved) === manifest.appState.installdir) {
152164
yield {
153165
launcher,

0 commit comments

Comments
 (0)