-
Notifications
You must be signed in to change notification settings - Fork 7
/
jd
executable file
·42 lines (36 loc) · 1.13 KB
/
jd
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
#!/usr/bin/env bash
set -euo pipefail
YP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
source ${YP_DIR}/sh/common.inc.sh
# shellcheck disable=SC1091
VSN=$(source ${YP_DIR}/CONST.inc && echo "${YP_JD_VSN}")
JD_URL=https://github.com/josephburnett/jd/releases/download
case ${OS_SHORT}-${ARCH_NORMALIZED} in
darwin-amd64|darwin-arm64)
BINARY=jd-${ARCH_NORMALIZED}-${OS_SHORT}
;;
linux-amd64|linux-arm64)
BINARY=jd-${ARCH_NORMALIZED}-${OS_SHORT}
;;
*)
echo_err "jd: ${OS_SHORT}-${ARCH_NORMALIZED} is an unsupported OS-ARCH."
exit 1
;;
esac
ASSET_LOCAL=${YP_DIR}/bin/jd-${VSN}/${BINARY}
ASSET_REMOTE=${JD_URL}/v${VSN}/${BINARY}
BINARY_LOCAL=${ASSET_LOCAL}
[[ -f ${BINARY_LOCAL} ]] || {
ASSET_LOCAL=${HOME}/.cache/yplatform/jd-${VSN}/${BINARY}
BINARY_LOCAL=${ASSET_LOCAL}
}
[[ -f ${BINARY_LOCAL} ]] || {
echo_info "Fetching ${ASSET_REMOTE}..."
mkdir -p $(dirname ${ASSET_LOCAL})
curl -qfsSL \
-o ${ASSET_LOCAL} \
${ASSET_REMOTE}
chmod +x ${BINARY_LOCAL}
}
echo_info "Proxying to 'jd' as ${BINARY_LOCAL}."
${BINARY_LOCAL} "$@"