Skip to content

Instantly share code, notes, and snippets.

@svyatoslavratov
Last active January 18, 2023 09:40
Show Gist options
  • Save svyatoslavratov/04044efceb3132dc1a54e414175303ee to your computer and use it in GitHub Desktop.
Save svyatoslavratov/04044efceb3132dc1a54e414175303ee to your computer and use it in GitHub Desktop.
Recursively remove node_modules from working directory.
#!/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