Last active
September 7, 2021 17:46
-
-
Save stronk7/82b51ed959b96a0bb9f08dce02ca1089 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clean any directory only containing phpunit.xml | |
# sure it was created for another branch and does | |
# not exist in current one. | |
candidates=$(find . -name phpunit.xml -not -path "./vendor/*" | xargs dirname | sort -r) | |
for candidate in ${candidates}; do | |
numfiles=$(ls -1 ${candidate} | wc -l) | |
if [[ ${numfiles} -eq 1 ]]; then | |
echo "Deleting empty ${candidate}" | |
rm -fr ${candidate} | |
# if that leads to an empty parent, delete it too | |
parent=$(dirname ${candidate}) | |
numfiles=$(ls -1 ${parent} | wc -l) | |
if [[ ${numfiles} -eq 0 ]]; then | |
echo "Deleting empty ${parent}" | |
rm -fr ${parent} | |
fi | |
fi | |
done | |
# Similar, only 4.0 and up have admin/tool/componentlibrary and we are leaving there | |
# some files (docs, hugo...) that make things break when version.php is searched. Clean | |
# it if missing version.php | |
if [[ ! -f admin/tool/componentlibrary/version.php ]]; then | |
rm -fr admin/tool/componentlibrary | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment