Skip to content

Commit 37927ba

Browse files
committed
fix run if pkg not installed
1 parent 7217dac commit 37927ba

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

bin/run

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env -S pkgx +deno bash +exo pipefail
22

3+
eval "$(pkgx --shellcode)"
4+
35
d="$(cd "$(dirname "$0")"/.. && pwd)"
46

57
get_parameters() {
@@ -10,23 +12,29 @@ get_parameters() {
1012
const pkg = await parse_pkg_str('$1')
1113
const entrypoint = await hooks.usePantry().project(pkg).yaml().then(x => x?.['entrypoint'])
1214
if (!entrypoint) Deno.exit(1)
13-
const prefix = (await hooks.useCellar().resolve(pkg)).path.string
14-
console.log(pkg.project, prefix, entrypoint)
15+
console.log(pkg.project, entrypoint)
1516
EoTS
1617
}
1718

18-
run() {
19-
project=$1
20-
shift
21-
cd "$1"
22-
shift
23-
eval "$(pkgx --shellcode)"
24-
env +$project
25-
"$@"
19+
get_keg() {
20+
deno run --config="$d/deno.jsonc" -A - <<EoTS
21+
import { hooks, semver } from 'pkgx'
22+
const pkg = {project: '$1', constraint: new semver.Range('*') }
23+
const prefix = (await hooks.useCellar().resolve(pkg)).path.string
24+
console.log(prefix)
25+
EoTS
2626
}
2727

2828
pkg=$1
2929
shift
3030

31+
# get project and entrypoint
3132
params=($(get_parameters $pkg))
32-
run "${params[@]}" "$@"
33+
34+
# install and add env
35+
env +${params[0]}
36+
37+
cd "$(get_keg ${params[0]})"
38+
39+
# run entrypoint
40+
"${params[@]:1}" "$@"

0 commit comments

Comments
 (0)