This commit is contained in:
asoseil 2018-02-09 00:17:02 +01:00
parent 21ce614026
commit 83134f9b8d
2 changed files with 9 additions and 3 deletions

View File

@ -348,6 +348,10 @@ func (p *Project) Validate(path string, fcheck bool) bool {
} }
// check for a valid ext or path // check for a valid ext or path
if e := ext(path); e != "" { if e := ext(path); e != "" {
if len(p.Watcher.Exts) == 0{
return false
}
// check ignored
for _, v := range p.Watcher.IgnoredExts { for _, v := range p.Watcher.IgnoredExts {
if v == e { if v == e {
return false return false
@ -355,6 +359,7 @@ func (p *Project) Validate(path string, fcheck bool) bool {
} }
// supported extensions // supported extensions
for index, v := range p.Watcher.Exts{ for index, v := range p.Watcher.Exts{
println(v)
if e == v { if e == v {
break break
} }

View File

@ -128,13 +128,14 @@ func TestProject_Validate(t *testing.T) {
r.Projects = append(r.Projects, Project{ r.Projects = append(r.Projects, Project{
parent: &r, parent: &r,
Watcher: Watch{ Watcher: Watch{
Exts: []string{"go","html"}, Exts: []string{},
IgnoredPaths: []string{"/test/ignore"}, IgnoredPaths: []string{"/test/ignore"},
}, },
}) })
for i, v := range data { for i, v := range data {
if r.Projects[0].Validate(i, false) != v { result := r.Projects[0].Validate(i, false)
t.Error("Unexpected error", i, "expected", v) if result != v {
t.Error("Unexpected error", i, "expected", v, result)
} }
} }
} }