Skip to content

Commit

Permalink
Fix usePantry().missing() throwing PantryNotFoundError
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs authored and mxcl committed Jan 17, 2025
1 parent 6075ded commit b59b1a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/hooks/usePantry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 1 addition & 7 deletions src/hooks/usePantry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit b59b1a0

Please sign in to comment.