mediawiki-skins-MinervaNeue/dev-scripts/svg_check.sh
jdlrobson 59a17fd0af Add tooling for svg size checking
also add pre-commit hook to ensure svgs are
compressed on commit

since extensions are accessible via http an .htaccess
is added to the dev-scripts folder for safety.

Bug: T170639
Change-Id: Ibcd5c29340d16c9cffc6e2eb90d33ee89b69874f
2017-07-14 11:07:08 -07:00

17 lines
502 B
Bash
Executable file

#!/usr/bin/env bash
found=0
for svgfile in `find resources -type f -name "*.svg"`; do
outfile="$svgfile.tmp"
node_modules/.bin/svgo --config .svgo.yml -i $svgfile -o $outfile -q
if [ $(wc -c $svgfile | awk '{print $1}') -gt $(wc -c $outfile | awk '{print $1}') ]; then
echo "File $svgfile is not compressed"
found=$((found + 1))
fi
rm $outfile
done
if [ $found -gt 0 ]; then
echo "Found $found uncompressed SVG files. Please compress the files and re-submit the patch"
exit 1
fi