| |
@@ -13,7 +13,27 @@
|
| |
echo ""
|
| |
echo "The preview is available at http://localhost:8080"
|
| |
echo ""
|
| |
- pushd ./public
|
| |
- python3 -m http.server 8080
|
| |
- popd
|
| |
+
|
| |
+ if [[ "$*" == *--refresh* ]]; then
|
| |
+ if ! [ -x "$(command -v inotifywait)" ]; then
|
| |
+ echo 'Error: inofitywait (inotify-utils) is not installed.' >&2
|
| |
+ exit 1
|
| |
+ fi
|
| |
+
|
| |
+ # Setup trap to kill this process group on ctrl+c.
|
| |
+ killgroup(){
|
| |
+ kill 0
|
| |
+ }
|
| |
+ trap killgroup SIGINT
|
| |
+
|
| |
+ # Run the Python's webserver.
|
| |
+ python3 -m http.server 8080 --directory ./public &
|
| |
+
|
| |
+ while inotifywait -r ./modules -e create -e moved_to -e modify; do
|
| |
+ echo "Documentation source changed, rebuilding ..."
|
| |
+ ./build.sh
|
| |
+ done
|
| |
+ else
|
| |
+ python3 -m http.server 8080 --directory ./public
|
| |
+ fi
|
| |
fi
|
| |