Skip to content

Commit

Permalink
use fsnotify fork with buffered done channel
Browse files Browse the repository at this point in the history
  • Loading branch information
clipperhouse committed Dec 20, 2014
1 parent e0ee0af commit fd1f8e5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"time"

"github.com/go-fsnotify/fsnotify"
"github.com/clipperhouse/fsnotify"
)

func watch(c config) error {
Expand Down Expand Up @@ -41,7 +41,7 @@ func watch(c config) error {
events = append(events, event)
}
case loopErr = <-watcher.Errors:
done <- struct{}{}
break Loop
case <-tick:
if len(events) == 0 {
continue
Expand All @@ -50,14 +50,12 @@ func watch(c config) error {
// stop watching while gen'ing files
loopErr = watcher.Remove(dir)
if loopErr != nil {
done <- struct{}{}
break Loop
}

// gen the files
loopErr = run(c)
if loopErr != nil {
done <- struct{}{}
break Loop
}

Expand All @@ -67,13 +65,11 @@ func watch(c config) error {
// resume watching
loopErr = watcher.Add(dir)
if loopErr != nil {
done <- struct{}{}
break Loop
}
case <-done:
break Loop
}
}
done <- struct{}{}
}()

<-done
Expand Down

0 comments on commit fd1f8e5

Please sign in to comment.