-
Notifications
You must be signed in to change notification settings - Fork 6
/
clean.sh
62 lines (49 loc) · 1.43 KB
/
clean.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Fati Iseni
WorkingDir="$(pwd)"
########## Make sure you're not deleting your whole computer :)
safetyCheck()
{
if [[ ( "$WorkingDir" = "" || "$WorkingDir" = "/" || "$WorkingDir" = '/c' || "$WorkingDir" = '/d' || "$WorkingDir" = 'c:\' || "$WorkingDir" = 'd:\' || "$WorkingDir" = 'C:\' || "$WorkingDir" = 'D:\') ]]; then
echo "Please cross check the WorkingDir value";
exit 1;
fi
}
########## Delete .vs directories.
deleteVsDirs()
{
echo "Deleting .vs files and directories...";
find "$WorkingDir/" -type d -name ".vs" -exec rm -rf {} \; > /dev/null 2>&1;
}
########## Delete content of bin and obj directories.
deleteTempContent()
{
echo "Deleting content of bin and obj directories...";
for i in `find "$WorkingDir/" -type d -name "bin" | sort -r`; do rm -rf "$i"/*; done
for i in `find "$WorkingDir/" -type d -name "obj" | sort -r`; do rm -rf "$i"/*; done
}
########## Cleaning content in wwwroot folder of the web project
cleanWwwRootContent()
{
echo "Cleaning content in wwwroot folder of the web project...";
wwwroot="$(find "$WorkingDir/" -type d -name "wwwroot")"
if [[ "$wwwroot" != "" ]]; then
rm -rf "$wwwroot/lib"/*;
rm -rf "$wwwroot/dist"/*;
fi
}
safetyCheck;
echo "";
if [ "$1" = "vs" ]; then
deleteVsDirs;
elif [ "$1" = "temp" ]; then
deleteTempContent;
elif [ "$1" = "www" ]; then
cleanWwwRootContent
elif [ "$1" = "all" ]; then
deleteVsDirs
deleteTempContent
cleanWwwRootContent
else
deleteTempContent;
fi