forked from liuchengxu/vim-clap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·55 lines (46 loc) · 993 Bytes
/
install.sh
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
#!/usr/bin/env bash
set -u
version=v0.24
APP=maple
DOWNLOAD_URL="https://github.com/liuchengxu/vim-clap/releases/download/$version"
exists() {
command -v "$1" >/dev/null 2>&1
}
download() {
local from=$1
local to=$2
if exists "curl"; then
curl -fLo "$to" "$from"
elif exists 'wget'; then
wget --output-document="$to" "$from"
else
echo 'curl or wget is required'
exit 1
fi
}
try_download() {
local asset=$1
if [ -z "${TMPDIR+x}" ]; then
rm -f bin/$APP
download "$DOWNLOAD_URL/$asset" bin/$APP
else
local temp=${TMPDIR}/maple
download "$DOWNLOAD_URL/$asset" "$temp"
mv "$temp" bin/$APP
fi
chmod a+x "bin/$APP"
}
main() {
arch=$(uname -sm)
case "${arch}" in
"Linux x86_64")
try_download "$APP"-x86_64-unknown-linux-musl ;;
"Darwin x86_64")
try_download "$APP"-x86_64-apple-darwin ;;
*)
echo "No prebuilt maple binary available for ${arch}."
exit 1
;;
esac
}
main