autoloaderchecker.sh 1.2 KB

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