From 3380644f843714d9e3e3912c605ec8eddb039ae6 Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Wed, 8 Jul 2020 15:10:07 +0200 Subject: Do not hardcode the path of the minify binary Make it so minify-assets.sh can also be run locally. --- scripts/minify-assets.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/minify-assets.sh b/scripts/minify-assets.sh index a0b5bfb7..7da94bf9 100755 --- a/scripts/minify-assets.sh +++ b/scripts/minify-assets.sh @@ -15,12 +15,29 @@ if ! [ -d "$TARGET" ]; then exit 1 fi +# Check if minify is in the PATH +which minify > /dev/null 2>&1 +# Check if the previous command has a 0 exit status +if [ $? -eq 0 ] +then + MINIFY_BIN=$(which minify) +else + # Backwards compatibility + if [ -f /scripts/minify ] + then + MINIFY_BIN=/scripts/minify + else + echo "minify binary not found in PATH. Exiting." + exit 1 + fi +fi + # Minify assets printf "Optimizing assets..." -printf "HTML..."; /scripts/minify $MINIFY_FLAGS --type=html --match=\.html -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true -printf "CSS..." ; /scripts/minify $MINIFY_FLAGS --type=css --match=\.css -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true -printf "JSON..."; /scripts/minify $MINIFY_FLAGS --type=json --match=\.json -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true -printf "SVG..." ; /scripts/minify $MINIFY_FLAGS --type=svg --match=\.svg -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true +printf "HTML..."; $MINIFY_BIN $MINIFY_FLAGS --type=html --match=\.html -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true +printf "CSS..." ; $MINIFY_BIN $MINIFY_FLAGS --type=css --match=\.css -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true +printf "JSON..."; $MINIFY_BIN $MINIFY_FLAGS --type=json --match=\.json -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true +printf "SVG..." ; $MINIFY_BIN $MINIFY_FLAGS --type=svg --match=\.svg -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true echo "Done" -- cgit v1.2.3