markdown
This script is designed to help manage the deletion of node_modules
directories within a specified directory.
./npkill <path>
or
bash npkill <path>
Replace <path>
with the directory where you want to search for and potentially delete node_modules
directories.
The script performs the following steps:
- Checks if the input directory path is provided.
- Searches for all
node_modules
directories under the given path. - Writes the list of found
node_modules
directories todelete.txt
. - Asks the user if they want to delete the listed directories (
y
), review them in your default editor (r
), or skip the deletion (n
). - If the user chooses to delete (
y
), it iterates throughdelete.txt
and deletes each directory. - If the user chooses to read (
r
), it opensdelete.txt
with your default editor for review. - If the user chooses not to delete (
n
) or if nonode_modules
directories are found, appropriate messages are displayed.
Suppose you have a project directory named my_project
containing several node_modules
directories you want to delete. You can run the script as follows:
npkill my_project
This will search for node_modules
directories within my_project
, list them in delete.txt
, and prompt you for further action.
All your deleted node modules are listed in delete.txt
Do you want to delete them? (yes/no/review)->[y/n/r]: