#!/bin/bash
#
# lurk -- a simple tool for making things happen when other things happen, namely
# rebuilding css and restarting the main celery worker
#
# To be run from the build vagrant box, e.g. /vagrant/bin/lurk
#


cd $(dirname $0)/..

while true;
do
    inotifywait engine/src core/src cli/src defaults/src jython/src -mqr -e CLOSE_WRITE -e CREATE  --format %w%f | while read file
    do
        notify-send "riskscape" "File changed..."
        echo -e "\n---------------\n"
        ./gradlew --no-daemon check && notify-send "riskscape" "Tests Passed" || notify-send "riskscape" "Tests Failed" --urgency critical --expire-time 5000
    done
done
