Skip to content

Instantly share code, notes, and snippets.

@madalinignisca
Created August 10, 2016 07:03
Show Gist options
  • Save madalinignisca/a879f6721980a111baf19ce15caacd74 to your computer and use it in GitHub Desktop.
Save madalinignisca/a879f6721980a111baf19ce15caacd74 to your computer and use it in GitHub Desktop.
git post-merge hook : update / install composer packages & composer itself
#!/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