Last active
September 26, 2018 06:24
-
-
Save alexandru/3f338500aa84538f2164b40b8a61e186 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Script that detects if Scala's SBT is installed and if | |
# not then it automatically downloads and installs it at | |
# a specified path. | |
# | |
# Author: Alexandru Nedelcu (https://alexn.org) | |
# | |
set -e | |
VERSION="1.2.3" | |
SBT_DIR="$(dirname $0)/.sbt" | |
if [ -x "$(command -v sbt)" ]; then | |
SBT_COMMAND="sbt" | |
elif ! [ -d "${SBT_DIR}" ]; then | |
DIR="$(mktemp -d)" | |
echo "Downloading SBT (temp dir: ${DIR}), please wait..." | |
wget -q "https://piccolo.link/sbt-$VERSION.tgz" -O ${DIR}/sbt.tgz | |
echo "Uncompressing and copying SBT ..." | |
tar xzf "${DIR}/sbt.tgz" -C "${DIR}" | |
mv "${DIR}/sbt" "${SBT_DIR}" | |
rm -rf "${DIR}" | |
SBT_COMMAND="${SBT_DIR}/bin/sbt" | |
else | |
SBT_COMMAND="${SBT_DIR}/bin/sbt" | |
fi | |
echo "Using SBT command: ${SBT_COMMAND}" | |
exec "${SBT_COMMAND}" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment