From 20292c885bd5f39d332d4316ef9faa14cf8ccf5a Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Mon, 4 Nov 2019 11:48:06 -0500 Subject: [PATCH] skip ignoreable directories --- parser/parser.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/parser/parser.go b/parser/parser.go index 6bb80b5..5052a9a 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -6,11 +6,12 @@ import ( "go/token" "os" "path/filepath" + "strings" "github.com/markbates/pkger/here" ) -// var DefaultIgnoredFolders = []string{".", "_", "vendor", "node_modules", "_fixtures", "testdata"} +var defaultIgnoredFolders = []string{".", "_", "vendor", "node_modules", "testdata"} func Parse(her here.Info) (Decls, error) { src, err := fromSource(her) @@ -43,6 +44,14 @@ func fromSource(her here.Info) (Decls, error) { if !info.IsDir() { return nil } + + base := filepath.Base(path) + for _, x := range defaultIgnoredFolders { + if strings.HasPrefix(base, x) { + return filepath.SkipDir + } + } + pkgs, err := parser.ParseDir(fset, path, nil, 0) if err != nil { return err