-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-push
100 lines (82 loc) · 1.77 KB
/
pre-push
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
VERSION="BaseAngular"
FAILED="\e[1m\e[31mFAILED\e[0m"
SUCCESS="\e[1m\e[32mSUCCESS\e[0m"
header()
{
clear
echo " \////"
echo " ( 0 0 )"
echo "----------------ooO-(_)-Ooo-----------------"
echo " git push breaker v${VERSION}"
echo ""
}
footer()
{
echo "--------------------------------------------"
echo " | | |"
echo " |||"
echo " ooO Ooo"
}
git_status()
{
echo -n " Checking your working directory..."
GIT_STATUS=$(git status --porcelain)
WD_CLEAN=`git status --porcelain | wc -l`
GIT_MESSAGE=$(echo 'git status --porcelain returned:'; \
echo "${GIT_STATUS}"; \
echo; \
echo "Please make sure your working directory is clean (You can use git stash to achieve this)")
error_checking $WD_CLEAN "${GIT_MESSAGE}"
}
javascript_checkstyle()
{
echo -n "Lint running... "
VERIFY=$(ng lint)
exit_code=$?
error_checking $exit_code "${VERIFY}"
cd - 2>&1 >/dev/null
}
angular_build()
{
echo -n "Angular build... "
BUILD=$(ng build --aot=true --prod --build-optimizer=false)
exit_code=$?
error_checking $exit_code "${BUILD}"
cd - 2>&1 >/dev/null
}
error_checking()
{
if [ $1 -ne 0 ]; then
echo -e $FAILED
echo
echo "$2"
echo
footer
exit 1
fi
echo -e $SUCCESS
}
karma(){
echo "Karma turned off."
#echo "Running Karma"
#karma=$(ng test)
#exit_code=$?
#if [[ $karma == *" 0 of 0 ERROR"* ]]; then
# echo -e $SUCCESS
#else
# echo -e $FAILED
# echo
# echo $karma
# echo
# footer
# exit 1
#fi
}
header
git_status
javascript_checkstyle
angular_build
karma
footer
exit 0