Last active
January 18, 2023 09:40
-
-
Save svyatoslavratov/04044efceb3132dc1a54e414175303ee to your computer and use it in GitHub Desktop.
Recursively remove node_modules from working directory.
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
#!/bin/bash | |
# Move this to `/usr/local/bin` and set `chmod +x remove-node-modules` for set as executable. | |
echo "Recursively remove node_modules from working directory." | |
while true; do | |
read -p "Do you want to proceed? (yes/no) " yn | |
remove() { | |
echo "Removing node_modules..." | |
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + | |
echo "node_modules was removed." | |
} | |
case $yn in | |
yes ) echo ok, we will proceed; remove; | |
break;; | |
no ) echo exiting...; | |
exit;; | |
* ) echo invalid response;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment