Skip to content

Commit b59b1a0

Browse files
felipecrsmxcl
authored andcommitted
Fix usePantry().missing() throwing PantryNotFoundError
1 parent 6075ded commit b59b1a0

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/hooks/usePantry.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ Deno.test("runtime.env", async () => {
4848
assertEquals(env.BAZ, prefix.join("bar.com/v1.2.3/baz").string)
4949
})
5050

51-
Deno.test("missing()", () => {
51+
Deno.test("missing - without cache", () => {
5252
useTestConfig()
5353
usePantry().prefix.rm({ recursive: true })
5454
assert(usePantry().missing())
5555
})
5656

57+
Deno.test("missing - with cache", () => {
58+
useTestConfig().cache.mkdir("p").join('pantry.db').touch()
59+
usePantry().prefix.rm({ recursive: true })
60+
assert(usePantry().missing())
61+
})
5762

5863
Deno.test("validatePackageRequirement - valid input", () => {
5964
const result = validatePackageRequirement("pkgx.sh/test", "^1.0.0")

src/hooks/usePantry.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,11 @@ export default function usePantry() {
275275
function pantry_paths(): Path[] {
276276
const rv: Path[] = []
277277

278-
if (prefix.isDirectory()) {
279-
rv.push(prefix)
280-
}
278+
rv.push(prefix)
281279
for (const path of useConfig().pantries.reverse()) {
282280
rv.unshift(path.join("projects"))
283281
}
284282

285-
if (rv.length == 0) {
286-
throw new PantryNotFoundError(prefix)
287-
}
288-
289283
return rv
290284
}
291285
}

0 commit comments

Comments
 (0)