-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhdc
More file actions
executable file
·30 lines (23 loc) · 793 Bytes
/
hdc
File metadata and controls
executable file
·30 lines (23 loc) · 793 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
#!/usr/bin/env bash
set -e
if ! [[ -x "$(command -v realpath)" ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install coreutils
fi
fi
SCRIPT_LOCATION=$(realpath "${0%/*}/")
if [ "${SCRIPT_LOCATION}" == "/usr/local/bin" ]; then
# When called via /usr/local/bin reverse symlink back to the project root
THIS_SCRIPT=$(realpath "/usr/local/bin/hdc")
ROOT=$(dirname "${THIS_SCRIPT}")
else
# Navigate to project root, allows execution from everywhere with correct relative links
ROOT=$SCRIPT_LOCATION
fi
HDC_CLI_PACKAGE="${ROOT}/packages/hdc_cli"
CLI_COMMITS=$(git -C "$ROOT" rev-list --count HEAD "${HDC_CLI_PACKAGE}")
EXE="${HDC_CLI_PACKAGE}/build/hdc_cli-$CLI_COMMITS.exe"
if [ ! -f "${EXE}" ]; then
sh "${HDC_CLI_PACKAGE}/tool/install_global.sh"
fi
"${EXE}" "$@"