-
Notifications
You must be signed in to change notification settings - Fork 0
/
install2.sh
executable file
·30 lines (25 loc) · 981 Bytes
/
install2.sh
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
#!/bin/bash
# USAGE: ./install.sh [version]
# will install the latest tool executable to your /usr/local/bin
set -e
echo "Installing..."
TMPDIR=${TMPDIR:-"/tmp"}
pushd "$TMPDIR" > /dev/null
mkdir -p complexity
pushd complexity > /dev/null;
distro=$(if [[ "$(uname -s)" == "Darwin" ]]; then echo "osx"; else echo "linux"; fi)
arch=$(uname -m)
if [ -n "$1" ]
then
echo "Will download and install v$1"
curl -sSL --fail -o complexity.zip "https://github.com/apiiro/code-complexity/releases/download/v$1/complexity-$1-$distro-$arch.zip"
else
curl -s --fail https://api.github.com/repos/apiiro/code-complexity/releases/latest | grep "browser_download_url.*$distro-$arch.zip" | cut -d : -f 2,3 | tr -d \" | xargs curl -sSL --fail -o complexity.zip
fi
unzip complexity.zip
chmod +x complexity-*
cp -f complexity-* /usr/local/bin/complexity
popd > /dev/null
rm -rf complexity
popd > /dev/null
echo "Done: $(complexity -v)"