stronk7

Untitled

Feb 6th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.16 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Stop on error
  4. set -e
  5.  
  6. # Move to base directory
  7. pushd "$(git rev-parse --show-toplevel)" > /dev/null
  8.  
  9. # Clean any directory only containing phpunit.xml
  10. # sure it was created for another branch and does
  11. # not exist in current one.
  12. candidates=$(find . -name phpunit.xml -not -path "./vendor/*" | xargs dirname | sort -r)
  13. for candidate in ${candidates}; do
  14.     numfiles=$(ls -1 ${candidate} | wc -l)
  15.     if [[ ${ "Deleting empty ${candidate}"
  16.        rm -fr ${candidate}
  17.        # if that leads to an empty parent, delete it too
  18.        parent=$(dirname ${candidate})
  19.        numfiles=$(ls -1 ${parent} | wc -l)
  20.        if [[ ${numfiles} -eq 0 ]]; then
  21.            echo "Deleting empty ${parent}"
  22.            rm -fr ${parent}
  23.        fi
  24.    fi
  25. done
  26.  
  27. drop=
  28. # First, look for the (d)rop option
  29. if [[ -n ${1} ]]; then
  30.    if [[ "${1}" == "d" ]] || [[ "${1}" == "drop" ]]; then
  31.        drop=1
  32.    fi
  33. fi
  34. if [[ -n ${drop} ]]; then
  35.    php admin/tool/phpunit/cli/util.php --drop
  36. else
  37.    php admin/tool/phpunit/cli/init.php
  38. fi
  39. php admin/tool/phpunit/cli/util.php --buildcomponentconfigs
  40.  
  41. # Move back to original directory
  42. popd > /dev/null
Advertisement
Add Comment
Please, Sign In to add comment