Skip to content

Commit

Permalink
Merge pull request #66 from stapelberg/fsnotify
Browse files Browse the repository at this point in the history
switch to maintained github.com/fsnotify/fsnotify
  • Loading branch information
robfig committed Nov 16, 2018
2 parents 91d31d4 + d56ce39 commit 1d4898e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -10,7 +10,7 @@ install:
- go get code.google.com/p/go.tools/cmd/cover || true
- go get github.com/andreyvit/diff
- go get github.com/robertkrimen/otto
- go get github.com/howeyc/fsnotify
- go get github.com/fsnotify/fsnotify
- go get github.com/robfig/gettext/po
script:
- go test github.com/robfig/soy/...
12 changes: 6 additions & 6 deletions bundle.go
Expand Up @@ -9,12 +9,12 @@ import (
"strings"
"time"

"github.com/fsnotify/fsnotify"
"github.com/robfig/soy/data"
"github.com/robfig/soy/parse"
"github.com/robfig/soy/parsepasses"
"github.com/robfig/soy/soyhtml"
"github.com/robfig/soy/template"
"github.com/howeyc/fsnotify"
)

// Logger is used to print notifications and compile errors when using the
Expand Down Expand Up @@ -79,7 +79,7 @@ func (b *Bundle) AddTemplateFile(filename string) *Bundle {
b.err = err
}
if b.err == nil && b.watcher != nil {
b.err = b.watcher.Watch(filename)
b.err = b.watcher.Add(filename)
}
return b.AddTemplateString(filename, string(content))
}
Expand Down Expand Up @@ -183,12 +183,12 @@ func (b *Bundle) CompileToTofu() (*soyhtml.Tofu, error) {
func (b *Bundle) recompiler(reg *template.Registry) {
for {
select {
case ev := <-b.watcher.Event:
case ev := <-b.watcher.Events:
// If it's a rename, then fsnotify has removed the watch.
// Add it back, after a delay.
if ev.IsRename() || ev.IsDelete() {
if ev.Op == fsnotify.Rename || ev.Op == fsnotify.Remove {
time.Sleep(10 * time.Millisecond)
if err := b.watcher.Watch(ev.Name); err != nil {
if err := b.watcher.Add(ev.Name); err != nil {
Logger.Println(err)
}
}
Expand All @@ -215,7 +215,7 @@ func (b *Bundle) recompiler(reg *template.Registry) {
*reg = *registry
Logger.Printf("update successful (%v)", ev)

case err := <-b.watcher.Error:
case err := <-b.watcher.Errors:
// Nothing to do with errors
Logger.Println(err)
}
Expand Down

0 comments on commit 1d4898e

Please sign in to comment.