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
|
set -e
|
||||||
cd "$(dirname "$0")/.."
|
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
|
pushd res >/dev/null
|
||||||
|
|
||||||
|
# crunch /docs/res/*.svg
|
||||||
for f in *.svg; do
|
for f in *.svg; do
|
||||||
svgo --multipass -q "$f" &
|
svgo --multipass -q "$f" &
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# crunch /docs/res/*.png
|
||||||
for f in *.png; do
|
for f in *.png; do
|
||||||
TMPNAME=.$f.tmp
|
TMPNAME=.$f.tmp
|
||||||
(pngcrush -q "$f" "$TMPNAME" && mv -f "$TMPNAME" "$f") &
|
(pngcrush -q "$f" "$TMPNAME" && mv -f "$TMPNAME" "$f") &
|
||||||
|
|
@ -18,6 +35,7 @@ popd >/dev/null
|
||||||
|
|
||||||
pushd samples/img >/dev/null
|
pushd samples/img >/dev/null
|
||||||
|
|
||||||
|
# crunch /docs/samples/img/*.png
|
||||||
for f in *.png; do
|
for f in *.png; do
|
||||||
TMPNAME=.$f.tmp
|
TMPNAME=.$f.tmp
|
||||||
if (echo "$f" | grep -q 'thumb'); then
|
if (echo "$f" | grep -q 'thumb'); then
|
||||||
|
|
@ -33,11 +51,12 @@ popd >/dev/null
|
||||||
|
|
||||||
pushd samples/icons >/dev/null
|
pushd samples/icons >/dev/null
|
||||||
|
|
||||||
|
# crunch /docs/samples/icons/*.svg
|
||||||
for f in *.svg; do
|
for f in *.svg; do
|
||||||
svgo --multipass -q "$f" &
|
svgo --multipass -q "$f" &
|
||||||
done
|
done
|
||||||
|
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
||||||
|
# wait for all background processes to exit
|
||||||
wait
|
wait
|
||||||
|
|
|
||||||
Reference in a new issue