validate method improved

This commit is contained in:
asoseil 2018-01-09 00:40:22 +01:00
parent a27819d0f6
commit b9efc9d317
1 changed files with 9 additions and 2 deletions

View File

@ -335,7 +335,7 @@ L:
} }
// Validate a file path // Validate a file path
func (p *Project) Validate(path string, fiche bool) bool { func (p *Project) Validate(path string, fcheck bool) bool {
if len(path) <= 0 { if len(path) <= 0 {
return false return false
} }
@ -349,6 +349,10 @@ func (p *Project) Validate(path string, fiche bool) bool {
if !array(e, p.Watcher.Exts) { if !array(e, p.Watcher.Exts) {
return false return false
} }
}else{
if !array(filepath.Base(path), p.Watcher.Paths) {
return false
}
} }
separator := string(os.PathSeparator) separator := string(os.PathSeparator)
// supported paths // supported paths
@ -360,8 +364,11 @@ func (p *Project) Validate(path string, fiche bool) bool {
} }
} }
// file check // file check
if fiche { if fcheck {
fi, err := os.Stat(path) fi, err := os.Stat(path)
if !fi.IsDir() && ext(path) == ""{
return false
}
if err != nil { if err != nil {
return false return false
} }