diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2020-07-08 16:10:07 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2020-07-08 16:50:26 +0300 |
commit | 3380644f843714d9e3e3912c605ec8eddb039ae6 (patch) | |
tree | a2fc5d10617d2044c22d0266d86a8b6f55c99f59 /scripts | |
parent | 1223670d0ada4534b1e8b60c7607a32f2197b9ac (diff) |
Do not hardcode the path of the minify binary
Make it so minify-assets.sh can also be run locally.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/minify-assets.sh | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/scripts/minify-assets.sh b/scripts/minify-assets.sh index a0b5bfb72..7da94bf90 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" |