summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@figma.com>2019-02-03 04:01:57 +0300
committerRasmus Andersson <rasmus@figma.com>2019-02-03 04:01:57 +0300
commit74e4a6cf743c384d7d6ccd1f937e774b41d30299 (patch)
treeffc23961b30868c9ed4e4a1d664c6abd665136f0
parent0e1b6090088586f7e8d12a83ee392cc52a2ad777 (diff)
downloadinter-74e4a6cf743c384d7d6ccd1f937e774b41d30299.tar.xz
website: add utility checks to optimize-resources.sh
-rwxr-xr-xdocs/_scripts/optimize-resources.sh21
1 files changed, 20 insertions, 1 deletions
diff --git a/docs/_scripts/optimize-resources.sh b/docs/_scripts/optimize-resources.sh
index 72d45b9f1..68f55324a 100755
--- a/docs/_scripts/optimize-resources.sh
+++ b/docs/_scripts/optimize-resources.sh
@@ -2,12 +2,29 @@
set -e
cd "$(dirname "$0")/.."
+if ! (which svgo >/dev/null); then
+ echo 'svgo not found in $PATH (try `brew install svgo` on mac)' >&2
+ exit 1
+fi
+
+if ! (which pngcrush >/dev/null); then
+ echo 'pngcrush not found in $PATH (try `brew install pngcrush` on mac)' >&2
+ exit 1
+fi
+
+if ! (which convert >/dev/null); then
+ echo 'convert not found in $PATH (try `brew install imagemagick` on mac)' >&2
+ exit 1
+fi
+
pushd res >/dev/null
+# crunch /docs/res/*.svg
for f in *.svg; do
svgo --multipass -q "$f" &
done
+# crunch /docs/res/*.png
for f in *.png; do
TMPNAME=.$f.tmp
(pngcrush -q "$f" "$TMPNAME" && mv -f "$TMPNAME" "$f") &
@@ -18,6 +35,7 @@ popd >/dev/null
pushd samples/img >/dev/null
+# crunch /docs/samples/img/*.png
for f in *.png; do
TMPNAME=.$f.tmp
if (echo "$f" | grep -q 'thumb'); then
@@ -33,11 +51,12 @@ popd >/dev/null
pushd samples/icons >/dev/null
+# crunch /docs/samples/icons/*.svg
for f in *.svg; do
svgo --multipass -q "$f" &
done
popd >/dev/null
-
+# wait for all background processes to exit
wait