Created
September 6, 2017 01:44
-
-
Save markryall/f9d1aeb2f345232bfb90aa19079496ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DONE_PATTERN="${1:-"webpack: Compiled successfully."}" | |
PROGRESS_PATTERN="${3:-"webpack: Compiling..."}" | |
ERROR_PATTERN="${3:-"ERROR"}" | |
HAS_ERROR=0 | |
main() { | |
tee >(update_status) | |
} | |
update_status() { | |
while read line | |
do | |
if [[ "$line" =~ "$DONE_PATTERN" ]]; then | |
if [ $HAS_ERROR -eq 0 ]; then | |
terminal-notifier -sound Glass -group calypso -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 | |
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 restarting | |
elif [[ "$line" =~ "app crashed" ]]; then | |
terminal-notifier -sound Basso -group calypso -message crashed | |
fi | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment