Created
May 30, 2012 12:07
-
-
Save dedico/2835854 to your computer and use it in GitHub Desktop.
Git pre-commit hook to precompile assets if anything changed in app/assets or vendor/assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# source rvm and .rvmrc if present | |
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm" | |
[ -s "$PWD/.rvmrc" ] && . "$PWD/.rvmrc" | |
should_precompile=0 | |
# check if anything changed in app/assets | |
if git diff-index --name-only HEAD | egrep '^app/assets' >/dev/null ; then | |
should_precompile=1 | |
fi | |
# check if anything changed in app/assets | |
if git diff-index --name-only HEAD | egrep '^vendor/assets' >/dev/null ; then | |
should_precompile=1 | |
fi | |
# precompile assets if any have been updated | |
if [ $should_precompile -eq 1 ]; then | |
echo 'Precompiling assets...' | |
rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets | |
git add public/assets/* | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment