Skip to content

Instantly share code, notes, and snippets.

@ryjen
Last active February 23, 2024 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryjen/e94e8257587ea5bbf4e7aaf48231878d to your computer and use it in GitHub Desktop.
Save ryjen/e94e8257587ea5bbf4e7aaf48231878d to your computer and use it in GitHub Desktop.
cleanup source project folders
#!/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