Skip to content

Instantly share code, notes, and snippets.

@arches
Created October 31, 2011 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arches/1328653 to your computer and use it in GitHub Desktop.
Save arches/1328653 to your computer and use it in GitHub Desktop.
Git commit hook to package assets using Jammit
#!/bin/bash
# to install, replace your .git/hooks/pre-commit with this file
if [ $staged_asset_count -gt 0 ]; then
if [ $changed_asset_count -eq 0 ]; then
echo "Packaging css/js assets with jammit..."
jammit -f
git add public/packaged # you might need to change this based on the package_path you use in your assets.yml
else
echo "Error: Cannot package css/js assets with jammit."
echo
echo "Jammit will run against the current state of the filesystem."
echo "Running Jammit now would create packaged assets that include unstaged changes."
echo "Please stage/stash/revert javascript and css."
exit 1
fi
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment