Skip to content

Instantly share code, notes, and snippets.

@meza meza/pre-commit
Created Jun 11, 2014

Embed
What would you like to do?
#!/bin/sh
#
# Pre-commit hooks
compileResult=0
# Compress stuff before committing
SRC_PATTERN="(\.css|\.scss|\.svg)"
git diff --cached --name-only | if egrep "$SRC_PATTERN"
then
echo "----> Found CSS changes, updating the compressed versions"
node_modules/.bin/grunt
compileResult=$?
git add assets/stylesheets/admin.css
git add assets/stylesheets/base.css
git add assets/assets.map
git add manifest.appcache
fi
# Exit code 1 means don't commit and 0 means do commit
[ $compileResult -ne 0 ] && exit 1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.