-
Notifications
You must be signed in to change notification settings - Fork 2
/
cmd.sh
executable file
·98 lines (83 loc) · 1.7 KB
/
cmd.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
#!/usr/bin/env bash
set -e
displayHelp() {
echo "Commands:"
echo "help Help"
echo "build-local Build website for local"
echo "build-deploy Build website for deployment"
echo "dev Run website in development mode"
echo "deploy Deploy website to remote server"
echo "clean-dev Clean cache and run website in development mode "
echo "update-vp Update vuepress version"
}
runSetup() {
./setup.sh
}
runBuildLocal() {
rm -rf src/.vuepress/.temp && vuepress build src
}
runBuildDeployPre() {
mkdir -p var
}
runBuildDeployAft() {
rm -rf var/dist && cp -rv src/.vuepress/dist/ var/ &&
rm -rf var/dist/res/.git &&
if grep -q "imagemin" package.json; then
echo -e "\nOptimizing images..."
node ./common/opt/imagemin.js
else
echo -e ""
fi
}
runDev() {
vuepress dev src
}
runDeploy() {
node ./common/deploy/index.mjs
}
runClean() {
vuepress dev src --clean-cache
}
runUpdateVP() {
npx vp-update
}
runUpdateRepo() {
git pull
}
if [ "$1" = "--debug" ]; then
export LTC_DEBUG=1
shift
fi
[ -n "${LTC_DEBUG}" ] && set -x
case "$1" in
"help")
displayHelp
;;
"build-local")
runBuildLocal
;;
"build-deploy")
runBuildDeployPre
runBuildLocal
runBuildDeployAft
;;
"dev")
runDev
;;
"deploy")
runDeploy
;;
"clean")
runClean
;;
"update-vp")
runUpdateVP
;;
*)
echo "Unknown commands: "$1"" >&2
echo ""
displayHelp >&2
exit 1
;;
esac
unset LTC_DEBUG