-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup-exercism
executable file
·59 lines (45 loc) · 1.06 KB
/
setup-exercism
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
#!/usr/bin/env bash
set -euo pipefail
declare -r name="exercism"
declare -r repo="exercism/cli"
move() {
local -r src="$1"
local -r dest="$2"
local -r dest_dir="$(dirname "$dest")"
if [ ! -d "${dest_dir}" ]; then
mkdir -p "${dest_dir}"
fi
mv "${src}" "${dest}"
}
setup_for_darwin() {
echo 'brew "exercism"' | brew bundle --no-lock --file=-
}
setup_for_debian() {
local -r prefix_path="${HOME}/.local"
local temp_dir
temp_dir="$(mktemp --directory /tmp/${name}--XXXXXXXXX)"
cd "${temp_dir}"
local pattern="*linux-x86_64.tar.gz"
if test "$(uname -m)" = "aarch64"; then
echo "unsupported arch"
exit 1
fi
echo "Downloading archive..."
gh release download --repo "${repo}" --pattern "${pattern}"
echo "Extracting archive..."
tar -xvzf "${temp_dir}"/*.tar.gz
echo "Setting up: ${name}"
move ./${name} "${prefix_path}/bin/${name}"
echo "Cleaning up..."
rm -rf "${temp_dir}"
echo "Done!"
}
case "${OSTYPE}" in
darwin*)
setup_for_darwin;;
linux*)
setup_for_debian;;
*)
echo "Unknown OS!"
exit 1;;
esac