autoloaderchecker.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 --1
  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 autoloader for ${app}"
  23. $COMPOSER_COMMAND dump-autoload -d ${app}/composer
  24. fi
  25. fi
  26. done
  27. files=`git diff --name-only`
  28. composerfile=false
  29. for file in $files
  30. do
  31. if [[ $file == *autoload_classmap* ]]
  32. then
  33. composerfile=true
  34. break
  35. fi
  36. done
  37. rm composer.phar
  38. echo
  39. if [ $composerfile = true ]
  40. then
  41. echo "The autoloaders are not up to date"
  42. echo "Please run: bash build/autoloaderchecker.sh"
  43. echo "And commit the result"
  44. exit 1
  45. else
  46. echo "Autoloader up to date. Carry on"
  47. exit 0
  48. fi