From 78e71785bd5112eec6a66d983717ffde798f438e Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 1 Jul 2019 06:22:59 -0700 Subject: scrape ./mill wrapper script for mill version, instead of exec-ing it --- main/mill-template | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 main/mill-template (limited to 'main') diff --git a/main/mill-template b/main/mill-template new file mode 100755 index 00000000..084f5e99 --- /dev/null +++ b/main/mill-template @@ -0,0 +1,31 @@ +#!/usr/bin/env sh + +# This is a wrapper script, that automatically download mill from GitHub release pages +# You can give the required mill version with MILL_VERSION env variable +# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION +DEFAULT_MILL_VERSION= + +set -e + +if [ -z "$MILL_VERSION" ] ; then + MILL_VERSION=$DEFAULT_MILL_VERSION +fi + +MILL_DOWNLOAD_PATH="$HOME/.mill/download" +MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/$MILL_VERSION" + +if [ ! -x "$MILL_EXEC_PATH" ] ; then + mkdir -p $MILL_DOWNLOAD_PATH + DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download + MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION" + curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" + chmod +x "$DOWNLOAD_FILE" + mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" + unset DOWNLOAD_FILE + unset MILL_DOWNLOAD_URL +fi + +unset MILL_DOWNLOAD_PATH +unset MILL_VERSION + +exec $MILL_EXEC_PATH "$@" \ No newline at end of file -- cgit v1.2.3