forked from wistingcn/WiLearning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·84 lines (71 loc) · 1 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
#! /bin/sh
if command -v cnpm &> /dev/null; then
alias npm_command='cnpm'
elif command -v npm &> /dev/null; then
alias npm_command='npm'
fi
npm_command -v &> /dev/null
if [ $? != 0 ];then
echo "Please install nodejs first!"
exit -1;
fi
# build server
build_server() {
if [ ! -d "node_modules" ];then
npm_command i
fi
npm run build
if [ $? != 0 ];then
exit -1;
fi
}
# build web client
build_web() {
cd web
if [ ! -d "node_modules" ];then
npm_command i
fi
npm run build
if [ $? != 0 ];then
exit -1;
fi
cp -a dist ../dist/web
cd ..
}
# build web admin
build_admin() {
cd admin
if [ ! -d "node_modules" ];then
npm_command i
fi
npm run build
if [ $? != 0 ];then
exit -1;
fi
cp -a dist ../dist/admin
cd ..
}
case "$1" in
all)
rm -rf dist/
build_server
build_web
build_admin
;;
server)
build_server
;;
admin)
rm -rf dist/admin
build_admin
;;
web)
rm -rf dist/web
build_web
;;
*)
echo
echo "Usage: ./build.sh [all/admin/web/server]"
echo
;;
esac