Skip to content

Instantly share code, notes, and snippets.

@andreburgaud
Created April 8, 2018 04:17
Show Gist options
  • Save andreburgaud/46df70bb8daeeaceb875a9861b150947 to your computer and use it in GitHub Desktop.
Save andreburgaud/46df70bb8daeeaceb875a9861b150947 to your computer and use it in GitHub Desktop.
Shell script to watch and reload Aqueduct https://aqueduct.io/ on MacOS (requires fswatch https://github.com/emcrisostomo/fswatch).
#! /bin/sh
# MIT License (https://opensource.org/licenses/MIT)
# Script to watch and reload Aqueduct (https://aqueduct.io/) on Mac OS.
# Requires fswatch (https://github.com/emcrisostomo/fswatch): brew install fswatch
# The server will automatically reload upon modification of dart files in lib directory
# To start development server: execute this script in an Aqueduct project folder.
# To quit: type CTRL+C in the terminal used to run the script.
SIGINT=2 # CTRL+C
start_server() {
aqueduct serve --detached
}
stop_server() {
aqueduct serve stop
}
restart_server() {
stop_server
start_server
}
quit_server() {
echo
stop_server
echo "Bye!"
exit 1
}
main() {
clear
start_server
fswatch -o -e ".*" -i "lib/[^.]*\\.dart$" -r . | while read event
do
clear
restart_server
done
clear
}
trap "quit_server" $SIGINT # trap CTRL+C
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment