Skip to content

Commit 3e08774

Browse files
committed
πŸ†• Added script to delete all node_modules from a folder
1 parent b8555fd commit 3e08774

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

β€Žerase_node_modules.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
FOLDER=$1;
3+
4+
if [ $# -eq 0 ]
5+
then
6+
echo "No arguments were supplied so we will clean this folder: ${PWD}";
7+
FOLDER=$(pwd);
8+
fi
9+
10+
11+
lines=$(find ${FOLDER} -name "node_modules" -type d -prune | wc -l)
12+
if [ $lines -eq 0 ]; then
13+
echo "\e[1m🧹 There is nothing to clean on the folder: ${FOLDER}";
14+
return 0;
15+
fi
16+
17+
18+
19+
echo "+=======================================================================+";
20+
echo "|\t\t\t πŸ—ƒ FILES AFFECTED \t\t\t\t|";
21+
echo "+=======================================================================+\n";
22+
find ${FOLDER} -name "node_modules" -type d -prune -print0 | xargs -r -0 du -chs
23+
echo "========================================================================\n";
24+
printf "πŸ—‘ Would you like to erase this folders (y/n): "
25+
read -r option
26+
case $option in
27+
'y'|'Y')
28+
find ${FOLDER} -name "node_modules" -type d -prune -print0 | xargs -r -0 rm -rf
29+
;;
30+
'n'|'N')
31+
return 0;
32+
;;
33+
*)
34+
echo "β›” \e[1mInvalid option";
35+
return 1;
36+
;;
37+
esac

0 commit comments

Comments
Β (0)