website: add utility checks to optimize-resources.sh
This commit is contained in:
parent
0e1b609008
commit
74e4a6cf74
1 changed files with 20 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Reference in a new issue