-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathjq
More file actions
executable file
·54 lines (48 loc) · 1.58 KB
/
Copy pathjq
File metadata and controls
executable file
·54 lines (48 loc) · 1.58 KB
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
#!/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_JQ_VSN}")
JQ_URL=https://github.com/stedolan/jq/releases/download
case ${OS_SHORT}-${ARCH_NORMALIZED} in
darwin-amd64)
# local arm64; not available in a github release
BINARY=jq-osx-${ARCH_NORMALIZED}
;;
darwin-arm64)
# local arm64; not available in a github release
BINARY=jq-osx-${ARCH_NORMALIZED}
# local arm64 hardlinks to /opt/homebrew/opt/oniguruma
brew list "oniguruma" >/dev/null 2>&1 || \
HOMEBREW_NO_AUTO_UPDATE=1 brew install oniguruma
;;
linux-386|linux-amd64)
BINARY=jq-${OS_SHORT}${ARCH_BIT}
;;
linux-arm64)
# local arm64; not available in a github release
BINARY=jq-${OS_SHORT}-${ARCH_NORMALIZED}
;;
*)
echo_err "jq: ${OS_SHORT}-${ARCH_NORMALIZED} is an unsupported OS-ARCH."
exit 1
;;
esac
ASSET_LOCAL=${YP_DIR}/bin/jq-${VSN}/${BINARY}
ASSET_REMOTE=${JQ_URL}/jq-${VSN}/${BINARY}
BINARY_LOCAL=${ASSET_LOCAL}
[[ -f ${BINARY_LOCAL} ]] || {
ASSET_LOCAL=${HOME}/.cache/yplatform/jq-${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 'jq' as ${BINARY_LOCAL}."
${BINARY_LOCAL} "$@"