Skip to content

Commit 5babde6

Browse files
committed
pkg edit binfile works
1 parent 40a1531 commit 5babde6

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

bin/pkg-edit

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,9 @@ if test -z "$1"; then
1616
PKGS="$(GIT_DIR="$x"/.git peek.sh --print-paths)"
1717
fi
1818
done
19-
else
20-
for x in $(echo "$TEA_PANTRY_PATH" | tr ':' '\n'); do
21-
if test -f "$x/projects/$1/package.yml"; then
22-
PKGS="$x/projects/$1/package.yml $PKGS"
23-
fi
24-
done
25-
if test -z "$PKGS"; then
26-
echo "error: \`$1\` not found in \`\$TEA_PANTRY_PATH\`" >&2
27-
exit 1
28-
fi
19+
elif ! PKGS="$(find.ts $1)"; then
20+
echo "error: \`$1\` not found in \`\$TEA_PANTRY_PATH\`" >&2
21+
exit 1
2922
fi
3023

3124
if test -z "$EDITOR"; then

libexec/fetch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ async function download({ dst, src }: { dst: Path, src: URL }) {
7171
// using cURL as deno’s fetch fails for certain sourceforge URLs
7272
// seemingly due to SSL certificate issues. cURL basically always works ¯\_(ツ)_/¯
7373
const proc = new Deno.Command("curl", {
74-
args: ["-fLo", dst.string, src.toString()]
74+
args: ["--fail", "--location", "--output", dst.string, src.toString()]
7575
})
7676
const status = await proc.spawn().status
7777
if (!status.success) {
7878
console.error({ dst, src })
79-
throw new Error()
79+
throw new Error(`cURL failed to download ${src}`)
8080
}
8181
return dst
8282
}

libexec/find.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env -S deno run --allow-read --allow-env
2+
3+
import { usePantry } from "hooks"
4+
5+
const pantry = usePantry()
6+
const arg = Deno.args[0]
7+
8+
for await (const entry of pantry.ls()) {
9+
if (entry.project === arg) {
10+
console.log(entry.path.string)
11+
Deno.exit(0)
12+
}
13+
if ((await pantry.getProvides(entry)).includes(arg)) {
14+
console.log(entry.path.string)
15+
Deno.exit(0)
16+
}
17+
}
18+
19+
Deno.exit(1)

0 commit comments

Comments
 (0)