Make realtime updating in runtime to be optional.
This commit is contained in:
parent
d634a64c4f
commit
f2bbf7f993
1 changed files with 21 additions and 3 deletions
24
run.sh
24
run.sh
|
@ -3,7 +3,7 @@
|
||||||
# Run jekyll site at http://127.0.0.1:4000
|
# Run jekyll site at http://127.0.0.1:4000
|
||||||
#
|
#
|
||||||
# Requirement:
|
# Requirement:
|
||||||
# fswatch › http://emcrisostomo.github.io/fswatch/
|
# Option '-r, --realtime' needs fswatch › http://emcrisostomo.github.io/fswatch/
|
||||||
#
|
#
|
||||||
# © 2019 Cotes Chung
|
# © 2019 Cotes Chung
|
||||||
# Published under MIT License
|
# Published under MIT License
|
||||||
|
@ -14,6 +14,7 @@ CONTAINER=.container
|
||||||
SYNC_TOOL=_scripts/sh/sync_monitor.sh
|
SYNC_TOOL=_scripts/sh/sync_monitor.sh
|
||||||
|
|
||||||
cmd="bundle exec jekyll s"
|
cmd="bundle exec jekyll s"
|
||||||
|
realtime=false
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
|
@ -26,7 +27,7 @@ help() {
|
||||||
echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
|
echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
|
||||||
echo " -h, --help Print the help information"
|
echo " -h, --help Print the help information"
|
||||||
echo " -t, --trace Show the full backtrace when an error occurs"
|
echo " -t, --trace Show the full backtrace when an error occurs"
|
||||||
|
echo " -r, --realtime Make the modified content updated in real time"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,12 +62,24 @@ check_unset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_command() {
|
||||||
|
if [[ -z $(command -v $1) ]]; then
|
||||||
|
echo "Error: command '$1' not found !"
|
||||||
|
echo "Hint: Get '$1' on <$2>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
init
|
init
|
||||||
|
|
||||||
cd $CONTAINER
|
cd $CONTAINER
|
||||||
python _scripts/py/init_all.py
|
python _scripts/py/init_all.py
|
||||||
fswatch -0 -e "\\$CONTAINER" -e "\.git" ${WORK_DIR} | xargs -0 -I {} bash ./${SYNC_TOOL} {} $WORK_DIR . &
|
|
||||||
|
if [[ $realtime = true ]]; then
|
||||||
|
fswatch -0 -e "\\$CONTAINER" -e "\.git" ${WORK_DIR} | xargs -0 -I {} bash ./${SYNC_TOOL} {} $WORK_DIR . &
|
||||||
|
fi
|
||||||
|
|
||||||
echo "\$ $cmd"
|
echo "\$ $cmd"
|
||||||
eval $cmd
|
eval $cmd
|
||||||
|
@ -105,6 +118,11 @@ do
|
||||||
cmd+=" -t"
|
cmd+=" -t"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-r|--realtime)
|
||||||
|
check_command fswatch 'http://emcrisostomo.github.io/fswatch/'
|
||||||
|
realtime=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
help
|
help
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue