"testing"
)
-func TestIgnoreDotFiles(t *testing.T) {
+func TestIgnoreDotFilesAndDirectories(t *testing.T) {
tests := []struct {
path string
ignore bool
}{
+ {".foobar/", true },
+ {"foobar/.barfoo/", true },
{"barfoo.md", false},
{"foobar/barfoo.md", false},
{"foobar/.barfoo.md", true},
}
for _, test := range tests {
- if ignored := ignoreDotFile(test.path); test.ignore != ignored {
+ if ignored := isNonProcessablePath(test.path); test.ignore != ignored {
t.Errorf("File not ignored. Expected: %t, got: %t", test.ignore, ignored)
}
}
}
if fi.IsDir() {
- if f.avoid(filePath) {
+ if f.avoid(filePath) || isNonProcessablePath(filePath) {
return filepath.SkipDir
}
return nil
} else {
- if ignoreDotFile(filePath) {
+ if isNonProcessablePath(filePath) {
return nil
}
data, err := ioutil.ReadFile(filePath)
return false
}
-func ignoreDotFile(filePath string) bool {
+func isNonProcessablePath(filePath string) bool {
base := filepath.Base(filePath)
if base[0] == '.' {
return true