Skip to content

Instantly share code, notes, and snippets.

@gbonanome
Last active December 28, 2015 19:08
Show Gist options
  • Save gbonanome/7547674 to your computer and use it in GitHub Desktop.
Save gbonanome/7547674 to your computer and use it in GitHub Desktop.
Pre-commit hook to make tasks like: run composer, bower, grunt (less, requirejs). Add everything. And so commit.
#!/bin/bash
### Check the DIR
DIR=$(git rev-parse --show-toplevel)
### Composer update
echo "Updating Composer"
if [ -e "$DIR/composer.json" ]; then
if [ -d "$DIR/vendor" ]; then
composer install
else
composer update
fi
fi
### Bower update
echo "Updating Bower"
bower install
### Run grunt default task
echo "Running Grunt"
grunt default
### Add everything to the commit
echo "Add what is needed to the index"
git add -A
### Do the commit
exit 0
@gbonanome
Copy link
Author

P.S. remember to chmod +x .git/hooks/pre-commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment