1
0

autoloaderchecker.sh 1.3 KB

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