forked from clj-kondo/clj-kondo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-clj-kondo
executable file
·72 lines (59 loc) · 1.95 KB
/
install-clj-kondo
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
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
# install script inspired by scripts for clojure and CircleCI CLI tool
# install latest version of clj-kondo or upgrades existing one
set -euo pipefail
default_install_dir="/usr/local/bin"
install_dir=$default_install_dir
default_download_dir="/tmp"
download_dir=$default_download_dir
print_help() {
echo "Installs latest version of clj-kondo."
echo -e
echo "Usage:"
echo "install [--dir <dir>] [--download-dir <download-dir>]"
echo -e
echo "Defaults:"
echo " * Installation directory: ${default_install_dir}"
echo " * Download directory: ${default_download_dir}"
exit 1
}
while [[ $# -gt 0 ]]
do
key="$1"
if [[ -z "${2:-}" ]]; then
print_help
fi
case $key in
--dir)
install_dir="$2"
shift
shift
;;
--download-dir)
download_dir="$2"
shift
shift
;;
*) # unknown option
print_help
shift
;;
esac
done
latest_release="$(curl -s https://raw.githubusercontent.com/borkdude/clj-kondo/master/resources/CLJ_KONDO_RELEASED_VERSION)"
case "$(uname -s)" in
Linux*) platform=linux;;
Darwin*) platform=macos;;
esac
download_url="https://github.com/borkdude/clj-kondo/releases/download/v$latest_release/clj-kondo-$latest_release-$platform-amd64.zip"
cd "$download_dir"
echo -e "Downloading $download_url to $download_dir"
curl -o "clj-kondo-$latest_release-$platform-amd64.zip" -sL "https://github.com/borkdude/clj-kondo/releases/download/v$latest_release/clj-kondo-$latest_release-$platform-amd64.zip"
unzip -qqo "clj-kondo-$latest_release-$platform-amd64.zip"
rm "clj-kondo-$latest_release-$platform-amd64.zip"
cd "$install_dir"
if [ -f clj-kondo ]; then
echo "Moving $install_dir/clj-kondo to $install_dir/clj-kondo.old"
fi
mv -f "$download_dir/clj-kondo" "$PWD/clj-kondo"
echo "Successfully installed clj-kondo in $install_dir"