2016-08-17 09:34:40 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-01-05 13:01:59 +03:00
|
|
|
COMPOSER_COMMAND=$(which "composer")
|
|
|
|
if [ "$COMPOSER_COMMAND" = '' ]
|
2016-08-17 09:34:40 +03:00
|
|
|
then
|
2017-01-05 13:01:59 +03:00
|
|
|
#No global composer found, try local or download it
|
|
|
|
if [ -e "composer.phar" ]
|
|
|
|
then
|
|
|
|
echo "Composer found: checking for update"
|
|
|
|
else
|
|
|
|
echo "Composer not found: fetching"
|
|
|
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
|
|
|
php composer-setup.php
|
|
|
|
php -r "unlink('composer-setup.php');"
|
|
|
|
fi
|
|
|
|
|
|
|
|
COMPOSER_COMMAND="php composer.phar"
|
2016-08-17 09:34:40 +03:00
|
|
|
else
|
2017-01-05 13:01:59 +03:00
|
|
|
echo "Global composer found: checking for update"
|
2016-08-17 09:34:40 +03:00
|
|
|
fi
|
|
|
|
|
2017-01-05 13:01:59 +03:00
|
|
|
#Make sure we are on the latest composer
|
|
|
|
$COMPOSER_COMMAND self-update
|
|
|
|
|
2016-08-17 09:34:40 +03:00
|
|
|
REPODIR=`git rev-parse --show-toplevel`
|
|
|
|
|
|
|
|
#Redump the autoloader
|
|
|
|
echo
|
|
|
|
echo "Regenerating autoloader"
|
2017-01-05 13:01:59 +03:00
|
|
|
$COMPOSER_COMMAND dump-autoload -d $REPODIR
|
2016-08-17 09:34:40 +03:00
|
|
|
|
|
|
|
files=`git diff --name-only`
|
|
|
|
composerfile=false
|
|
|
|
for file in $files
|
|
|
|
do
|
|
|
|
if [[ $file == lib/composer/* ]]
|
|
|
|
then
|
|
|
|
composerfile=true
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
if [ $composerfile = true ]
|
|
|
|
then
|
|
|
|
echo "The autoloader is not up to date"
|
|
|
|
echo "Please run: bash build/autoloaderchecker.sh"
|
|
|
|
echo "And commit the result"
|
2017-09-18 18:15:55 +03:00
|
|
|
git diff lib/composer
|
2016-08-17 09:34:40 +03:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Autoloader up to date. Carry on"
|
|
|
|
exit 0
|
|
|
|
fi
|