Skip to content

Commit f562527

Browse files
authored
Merge pull request #37 from sourceplusplus/issue-20
refactor
2 parents 2f908a6 + 6dc88f3 commit f562527

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

scripts/install.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,37 @@ check_cmd() {
2828
}
2929

3030
# Check if the commands to be used exist.
31-
for cmd in curl unzip; do
31+
for cmd in curl unzip awk; do
3232
check_cmd $cmd
3333
done
3434

3535
get_latest_release_number() {
3636
curl --silent "https://github.com/sourceplusplus/interface-cli/releases/latest" | sed 's#.*tag/\(.*\)\".*#\1#'
3737
}
3838

39+
# Convert the string to lower case.
40+
OS=$(echo $OS | awk '{print tolower($0)}')
41+
3942
# Get the latest version of spp-cli.
4043
VERSION=$(get_latest_release_number)
4144
echo "Installing spp-cli $VERSION"
4245

46+
ARCHIVE_NAME="spp-cli-$VERSION-${OS}64.zip"
47+
4348
# Download the binary package.
44-
curl -sSLO "https://github.com/sourceplusplus/interface-cli/releases/download/$VERSION/spp-cli-$VERSION-linux64.zip" > /dev/null
45-
if [ -f "spp-cli-$VERSION-linux64.zip" ]; then
46-
unzip -q spp-cli-$VERSION-linux64.zip
49+
curl -sSLO "https://github.com/sourceplusplus/interface-cli/releases/download/$VERSION/$ARCHIVE_NAME" > /dev/null
50+
if [ -f "$ARCHIVE_NAME" ]; then
51+
unzip -q $ARCHIVE_NAME
4752

4853
echo "Adding spp-cli to your PATH"
4954
# Add spp-cli to the environment variable PATH.
5055
sudo mv spp-cli /usr/local/bin/spp-cli
5156

5257
# Delete unnecessary files.
53-
rm "./spp-cli-$VERSION-linux64.zip"
58+
rm "./$ARCHIVE_NAME"
5459
echo "Installation complete."
5560

5661
echo "Type 'spp-cli --help' to get more information."
5762
else
58-
abort "Failed to download spp-cli-$VERSION-linux64.zip"
63+
abort "Failed to download $ARCHIVE_NAME"
5964
fi

0 commit comments

Comments
 (0)