better updater

This commit is contained in:
Yann Esposito (Yogsototh) 2013-11-27 11:55:00 +01:00
parent 36398843b7
commit b2df76b617

View file

@ -1,11 +1,26 @@
#!/usr/bin/env zsh #!/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() { relaunchCompilation() {
while read line; do while read line; do
if (( $( print -- $line | grep '.cabal-sandbox' | wc -l) == 0 )); then if (( $( print -- $line | grep '.cabal-sandbox' | wc -l) == 0 )); then
print "$line" (($latestThread>0)) && \
cabal install && \ (( $(ps x | awk "\$1 == $latestThread" | wc -l)>0 )) && {
./.cabal-sandbox/bin/test-holy-project print -- "\n${RED}STOPPED${RESET}"
kill $latestThread
}
print "${BLUE}$line${RESET}"
{ cabal install && \
./.cabal-sandbox/bin/test-holy-project } &
latestThread=$!
fi fi
done done
} }
@ -22,7 +37,7 @@ Darwin)
tmp=$(date +"%s") tmp=$(date +"%s")
t=$tmp t=$tmp
while true; do while true; do
tmp=$t tmp=$(( $t - 1 ))
t=$(date +"%s") t=$(date +"%s")
for fic in {src,test}/**/*.hs(.) *.cabal; do for fic in {src,test}/**/*.hs(.) *.cabal; do
# note to use on OS X, use "stat -f %m $checkfile" instead # note to use on OS X, use "stat -f %m $checkfile" instead