@@ -16,28 +16,26 @@ CONTAINER="${WORK_DIR}/.container"
1616
1717DEST=" ${WORK_DIR} /_site"
1818
19-
2019_help () {
2120 echo " Usage:"
2221 echo
2322 echo " bash build.sh [options]"
2423 echo
2524 echo " Options:"
26- echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
27- echo " -h, --help Print the help information"
28- echo " -d, --destination <DIR> Destination directory (defaults to ./_site)"
25+ echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
26+ echo " -h, --help Print the help information"
27+ echo " -d, --destination <DIR> Destination directory (defaults to ./_site)"
2928}
3029
31-
3230_init () {
3331 cd " $WORK_DIR "
3432
35- if [[ -d " $CONTAINER " ]]; then
33+ if [[ -d $CONTAINER ]]; then
3634 rm -rf " $CONTAINER "
3735 fi
3836
39- if [[ -d " _site " ]]; then
40- jekyll clean
37+ if [[ -d $DEST ]]; then
38+ bundle exec jekyll clean
4139 fi
4240
4341 local _temp=" $( mktemp -d) "
@@ -46,7 +44,6 @@ _init() {
4644 mv " $_temp " " $CONTAINER "
4745}
4846
49-
5047_build () {
5148 cd " $CONTAINER "
5249 echo " $ cd $( pwd) "
@@ -60,7 +57,7 @@ _build() {
6057 echo -e " \nBuild success, the site files have been placed in '${DEST} '."
6158
6259 if [[ -d " ${DEST} /.git" ]]; then
63- if [[ ! -z $( git -C " $DEST " status -s) ]]; then
60+ if [[ -n $( git -C " $DEST " status -s) ]]; then
6461 git -C " $DEST " add .
6562 git -C " $DEST " commit -m " [Automation] Update site files." -q
6663 echo -e " \nPlease push the changes of $DEST to remote master branch.\n"
@@ -70,37 +67,33 @@ _build() {
7067 cd .. && rm -rf " $CONTAINER "
7168}
7269
73-
7470_check_unset () {
75- if [[ -z ${1: +unset} ]]
76- then
71+ if [[ -z ${1: +unset} ]]; then
7772 _help
7873 exit 1
7974 fi
8075}
8176
82-
8377main () {
84- while [[ $# -gt 0 ]]
85- do
78+ while [[ $# -gt 0 ]]; do
8679 opt=" $1 "
8780 case $opt in
88- -b| --baseurl)
81+ -b | --baseurl)
8982 local _baseurl=" $2 "
90- if [[ -z " $_baseurl " ]]; then
83+ if [[ -z $_baseurl ]]; then
9184 _baseurl=' ""'
9285 fi
9386 CMD+=" -b $_baseurl "
9487 shift
9588 shift
9689 ;;
97- -d| --destination)
90+ -d | --destination)
9891 _check_unset " $2 "
9992 DEST=" $( realpath " $2 " ) "
100- shift ;
101- shift ;
93+ shift
94+ shift
10295 ;;
103- -h| --help)
96+ -h | --help)
10497 _help
10598 exit 0
10699 ;;
0 commit comments