Skip to content

Instantly share code, notes, and snippets.

@markryall
Created July 4, 2017 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markryall/712adecd62b906b9deb26ba6467682ab to your computer and use it in GitHub Desktop.
Save markryall/712adecd62b906b9deb26ba6467682ab to your computer and use it in GitHub Desktop.
make run | bash ~/Downloads/lmk
DONE_PATTERN="${1:-"bundle is now VALID"}"
#
PROGRESS_PATTERN="${3:-"bundle is now INVALID"}"
#
ERROR_PATTERN="${3:-"ERROR"}"
main() {
tee >(update_status)
}
update_status() {
while read line
do
if [[ "$line" =~ "$DONE_PATTERN" ]]; then
if [ $HAS_ERROR -eq 0 ]; then
terminal-notifier -group calypso -sound Submarine -message done!
else
terminal-notifier -sound Basso -group calypso -message yikes!
fi
elif [[ "$line" =~ "$PROGRESS_PATTERN" ]]; then
terminal-notifier -sound Bottle -group calypso -message starting!
HAS_ERROR=0
set_icon "$PROGRESS_COLOR"
elif [[ "$line" =~ "$ERROR_PATTERN" ]]; then
HAS_ERROR=1
# I tried to make the above generic enough but then wanted to also
# support `nodemon` in a way that didn't interfere with `make run`,
# hence the following mess with the literals:
# for npm run test-client:watch
elif [[ "$line" =~ "restarting due to changes" ]]; then
terminal-notifier -sound Bottle -group calypso -message starting!
elif [[ "$line" =~ "app crashed" ]]; then
terminal-notifier -sound Bottle -group calypso -message starting!
fi
done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment