-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathrun
More file actions
executable file
·37 lines (28 loc) · 917 Bytes
/
run
File metadata and controls
executable file
·37 lines (28 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env -S pkgx --quiet +deno bash -eo pipefail
eval "$(pkgx --quiet --shellcode)"
get_parameters() {
deno run --allow-read --allow-env - <<EoTS
import { hooks } from 'https://deno.land/x/libpkgx@v0.16.0/mod.ts'
const pkg = '$1'
const entrypoint = await hooks.usePantry().project(pkg).yaml().then(x => x?.['entrypoint'])
if (!entrypoint) Deno.exit(1)
console.log(pkg, entrypoint)
EoTS
}
get_keg() {
deno run --allow-read --allow-env - <<EoTS
import { hooks, semver } from 'https://deno.land/x/libpkgx@v0.16.0/mod.ts'
const pkg = {project: '$1', constraint: new semver.Range('*') }
const prefix = (await hooks.useCellar().resolve(pkg)).path.string
console.log(prefix)
EoTS
}
pkg=$1
shift
# get project and entrypoint
params=($(get_parameters $pkg))
# install and add env
env +${params[0]}
cd "$(get_keg ${params[0]})"
# run entrypoint
exec "${params[@]:1}" "$@"