-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·106 lines (91 loc) · 1.78 KB
/
build.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
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
101
102
103
104
105
106
#!/bin/sh
runsetup() {
echo "Compiling gulp build file..."
yarn setup || exit $?
}
runinstall() {
echo "Installing generator dependencies..."
yarn install --frozen-lockfile || exit $?
}
runbuild() {
echo "Building generators..."
yarn build || exit $?
}
runtest() {
echo "Running unit tests..."
if [ "$CI" = "true" ]; then
yarn test --coverage --ci || exit $?
else
yarn test || exit $?
fi
}
runpack() {
rm *.tgz
yarn pack || exit $?
}
installgenerator() {
find ~+ -maxdepth 2 -name "*.tgz" -exec yarn global add {} --force \; || exit $?
}
uninstallGenerator() {
yarn global remove generator-cake-addin || exit $?
}
BUILD="FALSE"
PACK="FALSE"
TEST="FALSE"
INSTALL="FALSE"
UNINSTALL="FALSE"
arguments=$@
if [ -z "$arguments" ]; then
arguments="--build --test"
fi
for i in $arguments; do
case $i in
--build)
BUILD="TRUE"
PACK="TRUE"
;;
--tests | --test)
TEST="TRUE"
;;
--install)
INSTALL="TRUE"
FOUND="FALSE"
PACK="TRUE"
for f in *.tgz
do
# If we get at least 1 result, then the file exist
# and we should quit
FOUND="TRUE"
break
done
if [ "$FOUND" == "TRUE" ]; then
BUILD="TRUE"
PACK="TRUE"
fi
;;
--uninstall)
UNINSTALL="TRUE"
;;
--pack)
PACK="TRUE"
;;
--no-pack)
PACK="FALSE"
;;
esac
done
if [ "$BUILD" = "TRUE" ]; then
runinstall && runsetup && runbuild
fi
if [ "$PACK" = "TRUE" ]; then
runpack
fi
if [ "$TEST" = "TRUE" ]; then
runtest
fi
if [ "$INSTALL" = "TRUE" ]; then
installgenerator
fi
if [ "$UNINSTALL" = "TRUE" ]; then
uninstallGenerator
fi