1
0

autoloaderchecker.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env bash
  2. COMPOSER_COMMAND=$(which "composer")
  3. if [ "$COMPOSER_COMMAND" = '' ]
  4. then
  5. #No global composer found, try local or download it
  6. if [ -e "composer.phar" ]
  7. then
  8. echo "Composer found: checking for update"
  9. else
  10. echo "Composer not found: fetching"
  11. php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  12. php composer-setup.php
  13. php -r "unlink('composer-setup.php');"
  14. fi
  15. COMPOSER_COMMAND="php composer.phar"
  16. else
  17. echo "Global composer found: checking for update"
  18. fi
  19. #Make sure we are on the latest composer
  20. $COMPOSER_COMMAND self-update
  21. REPODIR=`git rev-parse --show-toplevel`
  22. #Redump the autoloader
  23. echo
  24. echo "Regenerating autoloader"
  25. $COMPOSER_COMMAND dump-autoload -d $REPODIR
  26. files=`git diff --name-only`
  27. composerfile=false
  28. for file in $files
  29. do
  30. if [[ $file == lib/composer/* ]]
  31. then
  32. composerfile=true
  33. break
  34. fi
  35. done
  36. echo
  37. if [ $composerfile = true ]
  38. then
  39. echo "The autoloader is not up to date"
  40. echo "Please run: bash build/autoloaderchecker.sh"
  41. echo "And commit the result"
  42. exit 1
  43. else
  44. echo "Autoloader up to date. Carry on"
  45. exit 0
  46. fi