From 4aa4d27bb57a1cc672a8e6c54641e64483149052 Mon Sep 17 00:00:00 2001 From: alessio Date: Wed, 24 Aug 2016 14:17:42 +0200 Subject: [PATCH] walk path fixed #12 --- realize/watcher.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/realize/watcher.go b/realize/watcher.go index cfde096..374a0a4 100644 --- a/realize/watcher.go +++ b/realize/watcher.go @@ -113,8 +113,8 @@ func (p *Project) watching() { if err != nil { log.Fatal(Red(err)) } else { - go routines(p, channel, &wr) - p.reload = time.Now().Truncate(time.Second) + go routines(p, channel, &wr) + p.reload = time.Now().Truncate(time.Second) } } } @@ -185,18 +185,20 @@ func (p *Project) walks(watcher *fsnotify.Watcher) { wd, _ := os.Getwd() walk := func(path string, info os.FileInfo, err error) error { - if (info.IsDir() && len(filepath.Ext(path)) == 0 && !strings.HasPrefix(path, ".")) && !strings.Contains(path, "/.") || (inArray(filepath.Ext(path), p.Watcher.Exts)) { + if !p.ignore(path) { + if (info.IsDir() && len(filepath.Ext(path)) == 0 && !strings.HasPrefix(path, ".")) && !strings.Contains(path, "/.") || (inArray(filepath.Ext(path), p.Watcher.Exts)) { - if p.Watcher.Preview { - fmt.Println(pname(p.Name, 1), ":", path) - } - if err = watcher.Add(path); err != nil { - return filepath.SkipDir - } - if inArray(filepath.Ext(path), p.Watcher.Exts) { - files++ - } else { - folders++ + if p.Watcher.Preview { + fmt.Println(pname(p.Name, 1), ":", path) + } + if err = watcher.Add(path); err != nil { + return filepath.SkipDir + } + if inArray(filepath.Ext(path), p.Watcher.Exts) { + files++ + } else { + folders++ + } } } return nil