forked from WeDevCompany/BashUtilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherase_node_modules.sh
executable file
·37 lines (31 loc) · 1 KB
/
erase_node_modules.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
FOLDER=$1;
if [ $# -eq 0 ]
then
echo "No arguments were supplied so we will clean this folder: ${PWD}";
FOLDER=$(pwd);
fi
lines=$(find ${FOLDER} -name "node_modules" -type d -prune | wc -l)
if [ $lines -eq 0 ]; then
echo "\e[1m🧹 There is nothing to clean on the folder: ${FOLDER}";
return 0;
fi
echo "+=======================================================================+";
echo "|\t\t\t 🗃 FILES AFFECTED \t\t\t\t|";
echo "+=======================================================================+\n";
find ${FOLDER} -name "node_modules" -type d -prune -print0 | xargs -r -0 du -chs
echo "========================================================================\n";
printf "🗑 Would you like to erase this folders (y/n): "
read -r option
case $option in
'y'|'Y')
find ${FOLDER} -name "node_modules" -type d -prune -print0 | xargs -r -0 rm -rf
;;
'n'|'N')
return 0;
;;
*)
echo "⛔ \e[1mInvalid option";
return 1;
;;
esac