Skip to content

Instantly share code, notes, and snippets.

@qingwei91
Created June 17, 2020 11:11
Show Gist options
  • Save qingwei91/81dbcd4dd0b2e624c1454cce26de2102 to your computer and use it in GitHub Desktop.
Save qingwei91/81dbcd4dd0b2e624c1454cce26de2102 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# This is a wrapper script, that automatically download ammonite from GitHub release pages
# You can give the required mill version with AMM_VERSION env variable
# If no version is given, it falls back to the value of DEFAULT_AMM_VERSION
DEFAULT_AMM_VERSION=2.0.4
SCALA_VERSION=2.12
set -e
if [ -z "$AMM_VERSION" ] ; then
AMM_VERSION=$DEFAULT_AMM_VERSION
fi
AMM_DOWNLOAD_PATH="$HOME/.ammonite/download"
AMM_EXEC_PATH="${AMM_DOWNLOAD_PATH}/$AMM_VERSION_$SCALA_VERSION"
if [ ! -x "$AMM_EXEC_PATH" ] ; then
mkdir -p $AMM_DOWNLOAD_PATH
DOWNLOAD_FILE=$AMM_EXEC_PATH-tmp-download
AMM_DOWNLOAD_URL="https://github.com/lihaoyi/ammonite/releases/download/${AMM_VERSION%%-*}/$SCALA_VERSION-$AMM_VERSION"
curl --fail -L -o "$DOWNLOAD_FILE" "$AMM_DOWNLOAD_URL"
chmod +x "$DOWNLOAD_FILE"
mv "$DOWNLOAD_FILE" "$AMM_EXEC_PATH"
unset DOWNLOAD_FILE
unset AMM_DOWNLOAD_URL
fi
unset AMM_DOWNLOAD_PATH
unset AMM_VERSION
exec $AMM_EXEC_PATH "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment