fix: harden pi package resolution

This commit is contained in:
Peter Steinberger
2025-12-13 20:37:46 +00:00
parent 5a1687484c
commit 41dd3b11b7
2 changed files with 64 additions and 16 deletions

View File

@@ -97,7 +97,8 @@ function safeReadJson(filePath: string): Record<string, unknown> | null {
if (!exists(filePath)) return null;
const raw = fs.readFileSync(filePath, "utf-8");
const parsed = JSON.parse(raw) as unknown;
if (typeof parsed !== "object" || parsed === null) return null;
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
return null;
return parsed as Record<string, unknown>;
} catch {
return null;