Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2020-07-08 16:10:07 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2020-07-08 16:50:26 +0300
commit3380644f843714d9e3e3912c605ec8eddb039ae6 (patch)
treea2fc5d10617d2044c22d0266d86a8b6f55c99f59 /scripts
parent1223670d0ada4534b1e8b60c7607a32f2197b9ac (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-xscripts/minify-assets.sh25
1 files changed, 21 insertions, 4 deletions
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"