-
Notifications
You must be signed in to change notification settings - Fork 16
/
clean.sh
executable file
·55 lines (46 loc) · 1.13 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
#!/bin/bash
#Function loads configuration properties and generates project files
main(){
#Initialise
PROJECT_ROOT=$PWD
BUILD_PROPS_FILE=$PROJECT_ROOT/build.properties
#Clean
cleanProjectFolder || $?
cleanBuildFolder || $?
cleanDependencies || $?
# Exit batch script successfully
echo -e "\E[1;32mCLEAN SUCCESSFUL\E[;0m";
exit 0
}
#Clean up the old generated project folder
cleanProjectFolder(){
if [ -d "$PROJECT_ROOT/generated" ]; then
echo "Cleaning old generated folder..."
rm -rf $PROJECT_ROOT/generated
fi
}
#Clean up the old target build folder
cleanBuildFolder(){
if [ -d "$PROJECT_ROOT/build" ]; then
echo "Cleaning old build folder..."
rm -rf $PROJECT_ROOT/build
fi
}
#Clean up the old deps folder
cleanDependencies(){
if [ -d "$PROJECT_ROOT/deps" ]; then
echo "Cleaning old deps folder..."
rm -rf $PROJECT_ROOT/deps
fi
}
#Function to handle errors
function handleError() {
error_msg="CLEAN FAILED"
echo -e "\E[1;31m$error_msg\E[;0m";
exit 1;
}
# this will trap any errors or commands with non-zero exit status
# by calling function catch_errors()
trap handleError ERR;
# entry point of script
main