Last active
February 23, 2024 07:53
-
-
Save ryjen/e94e8257587ea5bbf4e7aaf48231878d to your computer and use it in GitHub Desktop.
cleanup source project folders
This file contains hidden or 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
#!/usr/bin/env bash | |
function clean_dir { | |
for f in $(find . -mindepth 1 -maxdepth 1 -type d -printf "%P\n"); do | |
if [ "$f" = "node_modules" ]; then | |
echo "Removing: ${PWD}/node_modules" | |
rm -rf "$f" | |
fi | |
if [ "$f" = ".git" ]; then | |
echo "Cleaning git repository: $PWD" | |
git gc --aggressive --prune=now | |
git maintenance run | |
fi | |
if [ "$f" = "gradlew" ]; then | |
echo "Cleaning gradle cache: $PWD" | |
./gradlew clean | |
fi | |
if [ "$f" = "Makefile" ]; then | |
echo "Cleaning make: $PWD" | |
make clean | |
fi | |
if [ -d "$f" ]; then | |
pushd "$f" >/dev/null | |
clean_dir "$f" | |
popd >/dev/null | |
fi | |
done | |
} | |
clean_dir "$PWD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment