autoloaderchecker.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 git check-ignore ${app} -q ; then
  20. echo
  21. echo "${app} is not shipped. Ignoring autoloader regeneration"
  22. continue
  23. fi
  24. if [[ -d $app ]]; then
  25. if [[ -e ${app}/composer/composer.json ]]; then
  26. echo
  27. echo "Regenerating composer files for ${app}"
  28. $COMPOSER_COMMAND i --no-dev -d ${app}/composer
  29. $COMPOSER_COMMAND dump-autoload -d ${app}/composer
  30. fi
  31. fi
  32. done
  33. files=`git diff --name-only`
  34. composerfile=false
  35. for file in $files
  36. do
  37. if [[ $file == *autoload_classmap* ]]
  38. then
  39. composerfile=true
  40. break
  41. fi
  42. done
  43. rm composer.phar
  44. echo
  45. if [ $composerfile = true ]
  46. then
  47. echo "The autoloaders are not up to date"
  48. echo "Please run: bash build/autoloaderchecker.sh"
  49. echo "And commit the result"
  50. exit 1
  51. else
  52. echo "Autoloader up to date. Carry on"
  53. exit 0
  54. fi