Css lint in git

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

This entry was posted in Notes and tagged , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared.

Subscribe without commenting