From 3516b41f824f2c7d3bbd96246de9d1d3371626eb Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Sat, 4 Jan 2025 12:55:59 -0300 Subject: [PATCH] Fix usePantry().missing() throwing PantryNotFoundError --- src/hooks/usePantry.test.ts | 7 ++++++- src/hooks/usePantry.ts | 8 +------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/hooks/usePantry.test.ts b/src/hooks/usePantry.test.ts index 099ecd4..49db256 100644 --- a/src/hooks/usePantry.test.ts +++ b/src/hooks/usePantry.test.ts @@ -48,12 +48,17 @@ Deno.test("runtime.env", async () => { assertEquals(env.BAZ, prefix.join("bar.com/v1.2.3/baz").string) }) -Deno.test("missing()", () => { +Deno.test("missing - without cache", () => { useTestConfig() usePantry().prefix.rm({ recursive: true }) assert(usePantry().missing()) }) +Deno.test("missing - with cache", () => { + useTestConfig().cache.mkdir("p").join('pantry.db').touch() + usePantry().prefix.rm({ recursive: true }) + assert(usePantry().missing()) +}) Deno.test("validatePackageRequirement - valid input", () => { const result = validatePackageRequirement("pkgx.sh/test", "^1.0.0") diff --git a/src/hooks/usePantry.ts b/src/hooks/usePantry.ts index 7178aff..f8d6ec8 100644 --- a/src/hooks/usePantry.ts +++ b/src/hooks/usePantry.ts @@ -275,17 +275,11 @@ export default function usePantry() { function pantry_paths(): Path[] { const rv: Path[] = [] - if (prefix.isDirectory()) { - rv.push(prefix) - } + rv.push(prefix) for (const path of useConfig().pantries.reverse()) { rv.unshift(path.join("projects")) } - if (rv.length == 0) { - throw new PantryNotFoundError(prefix) - } - return rv } }