From b2df76b61785779d2e00f5fae845f69ac7481c18 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Wed, 27 Nov 2013 11:55:00 +0100 Subject: [PATCH] better updater --- auto-update | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/auto-update b/auto-update index ae2309d..16d5aca 100755 --- a/auto-update +++ b/auto-update @@ -1,11 +1,26 @@ #!/usr/bin/env zsh +autoload colors +colors +for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do + eval $COLOR='$fg_no_bold[${(L)COLOR}]' + eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]' +done +eval RESET='$reset_color' + +latestThread=0 relaunchCompilation() { while read line; do if (( $( print -- $line | grep '.cabal-sandbox' | wc -l) == 0 )); then - print "$line" - cabal install && \ - ./.cabal-sandbox/bin/test-holy-project + (($latestThread>0)) && \ + (( $(ps x | awk "\$1 == $latestThread" | wc -l)>0 )) && { + print -- "\n${RED}STOPPED${RESET}" + kill $latestThread + } + print "${BLUE}$line${RESET}" + { cabal install && \ + ./.cabal-sandbox/bin/test-holy-project } & + latestThread=$! fi done } @@ -22,7 +37,7 @@ Darwin) tmp=$(date +"%s") t=$tmp while true; do - tmp=$t + tmp=$(( $t - 1 )) t=$(date +"%s") for fic in {src,test}/**/*.hs(.) *.cabal; do # note to use on OS X, use "stat -f %m $checkfile" instead