From 8ed2bc026c225fe2e14d3fdacc15abcace2246d1 Mon Sep 17 00:00:00 2001 From: cmontemuino <1761056+cmontemuino@users.noreply.github.com> Date: Fri, 1 Nov 2024 09:10:05 +0100 Subject: [PATCH] ci: harmonize amm-template.sh script with mill script PROBLEM: `amm-template.sh` is downloading the ammnite executable into `${HOME}/.ammnite/download`. It is not necessarily wrong, but does not follow the same pattern as in `mill` script. Having an harmonized way to keep downloaded data is always preferred. SOLUTION: adopt the mechanism from `mill` script to download files, which also takes into account the existence of `${XDG_CACHE_HOME}` variable. Signed-off-by: cmontemuino <1761056+cmontemuino@users.noreply.github.com> --- amm-template.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/amm-template.sh b/amm-template.sh index 65613b8b1..a94a8fc6b 100755 --- a/amm-template.sh +++ b/amm-template.sh @@ -14,7 +14,11 @@ if [ -z "$SCALA_VERSION" ] ; then SCALA_VERSION=$DEFAULT_SCALA_VERSION fi -AMM_DOWNLOAD_PATH="$HOME/.ammonite/download" +if [ "x${XDG_CACHE_HOME}" != "x" ] ; then + AMM_DOWNLOAD_PATH="${XDG_CACHE_HOME}/ammonite/download" +else + AMM_DOWNLOAD_PATH="${HOME}/.cache/ammonite/download" +fi AMM_EXEC_PATH="${AMM_DOWNLOAD_PATH}/${AMM_VERSION}_$SCALA_VERSION" if [ ! -x "$AMM_EXEC_PATH" ] ; then