Created
August 10, 2016 07:03
-
-
Save madalinignisca/a879f6721980a111baf19ce15caacd74 to your computer and use it in GitHub Desktop.
git post-merge hook : update / install composer packages & composer itself
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 | |
# thanks http://www.jenssegers.be/blog/46/deploying-websites-with-git-and-composer- | |
# replace folder | |
cd "`dirname $0`/../../application/config" | |
# Check if a composer.json file is present | |
if [ -f composer.json ]; then | |
# Detect composer binary | |
if which composer >/dev/null; then | |
composer='composer' | |
elif which composer.phar >/dev/null; then | |
composer='composer.phar' | |
else | |
# Install composer | |
curl -s http://getcomposer.org/installer | php >/dev/null | |
composer='php composer.phar' | |
fi | |
# Run composer if composer.json is updated | |
if [ ! -e composer.lock ] || [ composer.json -nt composer.lock ]; then | |
# Install or update depending on lock file | |
echo "Updating Composer packages" | |
[ ! -f composer.lock ] && $composer install || $composer update | |
else | |
# Regenerating autoload files | |
echo "Composer packages up to date" | |
$composer dump-autoload | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment