-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsetup-util-deno
executable file
·101 lines (90 loc) · 3.4 KB
/
setup-util-deno
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
# https://deno.land/#installation
# https://github.com/denoland/deno_install
# https://github.com/denoland/deno/releases
# deno-aarch64-apple-darwin.zip
# deno-aarch64-unknown-linux-gnu.zip
# deno-x86_64-apple-darwin.zip
# deno-x86_64-pc-windows-msvc.zip
# deno-x86_64-unknown-linux-gnu.zip
# denort-aarch64-apple-darwin.zip
# denort-aarch64-unknown-linux-gnu.zip
# denort-x86_64-apple-darwin.zip
# denort-x86_64-pc-windows-msvc.zip
# denort-x86_64-unknown-linux-gnu.zip
# https://github.com/LukeChannings/deno-arm64/releases
# deno-linux-arm64.zip
# arm64
# https://github.com/denoland/deno/issues/4862
# https://github.com/LukeChannings/deno-arm64
# now mainlined
# https://repology.org/project/deno/versions
# Note that for Alpine, Alpine uses musl, whereas Deno only provides gnu builds, as such executing the gnu build on Alpine fails with 127
# https://github.com/denoland/deno_docker/issues/240 - request for apk package
# https://github.com/denoland/deno/issues/3711 - request for musl build
# https://pkgs.alpinelinux.org/packages?name=deno - community build for alpine
function setup_util_deno() (
source "$DOROTHY/sources/bash.bash"
# check if deno is installed via snap, if so, uninstall it
# if [--classic] worked, we could do [ | grep -q 'classic$'] however --classic doesn't work either
if __command_exists -- deno && is-snap && snap list deno &>/dev/null; then
setup-util --quiet --uninstall --cli=deno SNAP='deno'
fi
# improve performance for detectable utilities with conditional assets
if setup-util "$@" --check --cli=deno; then
return 0
fi
# setup
# Don't use the official yet setupid [INSTALLER='https://deno.land/install.sh'], unlike setup-util, it ignores XDG and dumps the bin in [$HOME/.deno/bin/deno] with nothing else in [$HOME/.deno] except that bin, making it useless without slow clutter of env modifications
# Don't use [SNAP='deno'] without --classic as it faces [Permission denied (os error 13)] when running on scripts outside the snap: https://github.com/denoland/deno/issues/5816
# However, Don't use [SNAP='deno --classic'] either as --classic is ignored sometimes with [Warning: flag --classic ignored for strictly confined snap deno]
local arch options=(
--cli='deno'
"$@"
APK_REPO='http://dl-cdn.alpinelinux.org/alpine/edge/community'
APK='deno'
AUR='deno' # ARCH
BREW='deno'
CARGO='deno'
CHOCO='deno'
PORT='deno'
SCOOP='deno'
WINGET='deno'
)
arch="$(get-arch)"
function get_github_asset_url {
github-download \
--dry \
--slug="${2:-"denoland/deno"}" \
--latest \
--asset-regexp="$(echo-escape-regexp -- "$1")$" | echo-first-line || :
}
function add_download_option {
options+=(
DOWNLOAD="$(get_github_asset_url "$1")"
DOWNLOAD_ARCHIVE_GLOB="$2"
)
}
if is-mac; then
if test "$arch" = 'a64'; then
add_download_option 'deno-aarch64-apple-darwin.zip' 'deno'
elif test "$arch" = 'x64'; then
add_download_option 'deno-x86_64-apple-darwin.zip' 'deno'
fi
elif is-linux; then
if test "$arch" = 'a64'; then
add_download_option 'deno-aarch64-unknown-linux-gnu.zip' 'deno'
elif test "$arch" = 'x64'; then
add_download_option 'deno-x86_64-unknown-linux-gnu.zip' 'deno'
fi
elif is-wsl; then
if test "$arch" = 'x64'; then
add_download_option 'deno-x86_64-pc-windows-msvc.zip' 'deno.exe'
fi
fi
setup-util "${options[@]}"
)
# fire if invoked standalone
if test "$0" = "${BASH_SOURCE[0]}"; then
setup_util_deno "$@"
fi