walk path fixed #12

This commit is contained in:
alessio 2016-08-24 14:17:42 +02:00
parent 74e540bdbf
commit 4aa4d27bb5

View File

@ -113,8 +113,8 @@ func (p *Project) watching() {
if err != nil { if err != nil {
log.Fatal(Red(err)) log.Fatal(Red(err))
} else { } else {
go routines(p, channel, &wr) go routines(p, channel, &wr)
p.reload = time.Now().Truncate(time.Second) p.reload = time.Now().Truncate(time.Second)
} }
} }
} }
@ -185,18 +185,20 @@ func (p *Project) walks(watcher *fsnotify.Watcher) {
wd, _ := os.Getwd() wd, _ := os.Getwd()
walk := func(path string, info os.FileInfo, err error) error { 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 { if p.Watcher.Preview {
fmt.Println(pname(p.Name, 1), ":", path) fmt.Println(pname(p.Name, 1), ":", path)
} }
if err = watcher.Add(path); err != nil { if err = watcher.Add(path); err != nil {
return filepath.SkipDir return filepath.SkipDir
} }
if inArray(filepath.Ext(path), p.Watcher.Exts) { if inArray(filepath.Ext(path), p.Watcher.Exts) {
files++ files++
} else { } else {
folders++ folders++
}
} }
} }
return nil return nil