Skip to content

Instantly share code, notes, and snippets.

@meza
Created June 11, 2014 20:05
Show Gist options
  • Save meza/a9b8a2a634e604e7bd40 to your computer and use it in GitHub Desktop.
Save meza/a9b8a2a634e604e7bd40 to your computer and use it in GitHub Desktop.
#!/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