33# Run jekyll site at http://127.0.0.1:4000
44#
55# Requirement:
6- # fswatch › http://emcrisostomo.github.io/fswatch/
6+ # Option '-r, --realtime' needs fswatch › http://emcrisostomo.github.io/fswatch/
77#
88# © 2019 Cotes Chung
99# Published under MIT License
@@ -14,6 +14,7 @@ CONTAINER=.container
1414SYNC_TOOL=_scripts/sh/sync_monitor.sh
1515
1616cmd=" bundle exec jekyll s"
17+ realtime=false
1718
1819help () {
1920 echo " Usage:"
@@ -26,7 +27,7 @@ help() {
2627 echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
2728 echo " -h, --help Print the help information"
2829 echo " -t, --trace Show the full backtrace when an error occurs"
29-
30+ echo " -r, --realtime Make the modified content updated in real time "
3031}
3132
3233
@@ -61,12 +62,24 @@ check_unset() {
6162}
6263
6364
65+ check_command () {
66+ if [[ -z $( command -v $1 ) ]]; then
67+ echo " Error: command '$1 ' not found !"
68+ echo " Hint: Get '$1 ' on <$2 >"
69+ exit 1
70+ fi
71+ }
72+
73+
6474main () {
6575 init
6676
6777 cd $CONTAINER
6878 python _scripts/py/init_all.py
69- fswatch -0 -e " \\ $CONTAINER " -e " \.git" ${WORK_DIR} | xargs -0 -I {} bash ./${SYNC_TOOL} {} $WORK_DIR . &
79+
80+ if [[ $realtime = true ]]; then
81+ fswatch -0 -e " \\ $CONTAINER " -e " \.git" ${WORK_DIR} | xargs -0 -I {} bash ./${SYNC_TOOL} {} $WORK_DIR . &
82+ fi
7083
7184 echo " \$ $cmd "
7285 eval $cmd
105118 cmd+=" -t"
106119 shift
107120 ;;
121+ -r|--realtime)
122+ check_command fswatch ' http://emcrisostomo.github.io/fswatch/'
123+ realtime=true
124+ shift
125+ ;;
108126 -h|--help)
109127 help
110128 exit 0
0 commit comments