Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

fix(fs): skip dir #173

Merged
merged 2 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion walker/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import (
func WalkDir(root string, f WalkFunc) error {
// walk function called for every path found
walkFn := func(pathname string, fi os.FileInfo) error {
if isIgnored(pathname) {
if fi.IsDir() {
return nil
} else if isIgnored(pathname) {
return filepath.SkipDir
}
pathname = filepath.Clean(pathname)
Expand Down
3 changes: 2 additions & 1 deletion walker/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ func TestWalkDir(t *testing.T) {
err = walker.WalkDir("testdata/fs", func(filePath string, info os.FileInfo, opener analyzer.Opener) error {
return errors.New("error")
})
require.EqualError(t, err, "failed to analyze file: error", "sad path")
require.NotNil(t, err)
require.Contains(t, err.Error(), "failed to analyze file: error", "sad path")
}