forked from mirror/pkger
skip ignoreable directories
This commit is contained in:
parent
3cbd07f98b
commit
20292c885b
|
@ -6,11 +6,12 @@ import (
|
||||||
"go/token"
|
"go/token"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/markbates/pkger/here"
|
"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) {
|
func Parse(her here.Info) (Decls, error) {
|
||||||
src, err := fromSource(her)
|
src, err := fromSource(her)
|
||||||
|
@ -43,6 +44,14 @@ func fromSource(her here.Info) (Decls, error) {
|
||||||
if !info.IsDir() {
|
if !info.IsDir() {
|
||||||
return nil
|
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)
|
pkgs, err := parser.ParseDir(fset, path, nil, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue