Created
May 31, 2023 15:17
-
-
Save orzklv/dd938d93ab9652de44b9c77fcb5f5e32 to your computer and use it in GitHub Desktop.
If you're an aesthetic developer who keeps all projects in a single developer like I do at ~/Developer, this script will help you to clean cached dependencies of your projects and clean some space~
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
cleaner() { | |
# my DEVSPACE is ~/Developer, set your own DEVSPACE and add it to | |
# your ~/.zshrc or ~/.bashrc file to let this script detect it | |
# check if DEVSPACE is set, if not, set it to the current directory | |
if [ -z "$DEVSPACE" ]; then | |
DEVSPACE="$(pwd)"; | |
fi | |
# change current directory to DEVSPACE | |
cd $DEVSPACE; | |
# loop through project folders in current path and ... | |
for folder in $(/usr/bin/find . -type d -maxdepth 1); do | |
# if package.json exists, delete node_momodules folder | |
if [ -f "$folder/package.json" ]; then | |
echo "Deleting node_modules folder in $folder" | |
rm -rf "$folder/node_modules" | |
# if cargo.toml exists, delete target folder | |
elif [ -f "$folder/Cargo.toml" ]; then | |
echo "Deleting target folder in $folder" | |
rm -rf "$folder/target" | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment