-
Notifications
You must be signed in to change notification settings - Fork 0
/
millw
executable file
·49 lines (38 loc) · 1.25 KB
/
millw
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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 parameter
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
DEFAULT_MILL_VERSION=0.3.6
set -e
if [ -f ".mill-version" ] ; then
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
fi
if [ "x$1" = "x--mill-version" ] ; then
shift
if [ "x$1" != "x" ] ; then
MILL_VERSION="$1"
shift
else
echo "You specified --mill-version without a version."
echo "Please provide a version that matches one provided on"
echo "https://github.com/lihaoyi/mill/releases"
false
fi
fi
if [ "x${MILL_VERSION}" = "x" ] ; then
MILL_VERSION="${DEFAULT_MILL_VERSION}"
fi
MILL_DOWNLOAD_PATH="${HOME}/.mill/download"
MILL="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"
if [ ! -x "${MILL}" ] ; then
DOWNLOAD_FILE=$(mktemp mill.XXXX)
# TODO: handle command not found
curl -L -o "${DOWNLOAD_FILE}" "https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/${MILL_VERSION}"
chmod +x "${DOWNLOAD_FILE}"
mkdir -p "${MILL_DOWNLOAD_PATH}"
mv "${DOWNLOAD_FILE}" "${MILL}"
unset DOWNLOAD_FILE
fi
unset MILL_DOWNLOAD_PATH
unset MILL_VERSION
exec $MILL "$@"