A short git hook (pre-commit) to check for css sanity before I commit changes to the git repo.
Css validation done with the cssparse tool from css-utils (python).
The idiom to get a list of staged git files and filter it is handy on other pre-commit scripts.
for css in $(git diff-index --name-only --cached HEAD -- | grep '\.css$'); do
if cssparse $css 2>&1 | grep '^ERROR' ; then
exit 1
else
echo "css files validated"
exit 0
fi
done
