mirror of https://github.com/markbates/pkger.git
one headlight
This commit is contained in:
parent
da705a9bbc
commit
fa7d8c2b96
|
@ -2,11 +2,11 @@ module github.com/markbates/pkger/internal/examples/app
|
|||
|
||||
go 1.12
|
||||
|
||||
replace github.com/markbates/pkger => ../../../
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.36.0 // indirect
|
||||
github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c // indirect
|
||||
github.com/gobuffalo/buffalo v0.14.7 // indirect
|
||||
github.com/markbates/pkger v0.0.0-00010101000000-000000000000
|
||||
github.com/markbates/pkger v0.0.0
|
||||
)
|
||||
|
||||
replace github.com/markbates/pkger => ../../../
|
||||
|
|
|
@ -14,13 +14,15 @@ var DefaultIgnoredFolders = []string{".", "_", "vendor", "node_modules", "_fixtu
|
|||
|
||||
func Parse(name string) (Results, error) {
|
||||
var r Results
|
||||
c, err := pkgs.Current()
|
||||
if err != nil {
|
||||
return r, err
|
||||
}
|
||||
|
||||
if name == "" || name == "." {
|
||||
c, err := pkgs.Current()
|
||||
if err != nil {
|
||||
return r, err
|
||||
}
|
||||
name = c.ImportPath
|
||||
}
|
||||
|
||||
pt, err := paths.Parse(name)
|
||||
if err != nil {
|
||||
return r, err
|
||||
|
@ -34,18 +36,37 @@ func Parse(name string) (Results, error) {
|
|||
}
|
||||
|
||||
m := map[paths.Path]bool{}
|
||||
|
||||
root := r.Path.Name
|
||||
if !strings.HasPrefix(root, string(filepath.Separator)) {
|
||||
root = string(filepath.Separator) + root
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(root, her.Dir) {
|
||||
root = filepath.Join(her.Dir, root)
|
||||
}
|
||||
|
||||
if name != her.Dir {
|
||||
_, err = os.Stat(filepath.Join(root, "go.mod"))
|
||||
if err == nil {
|
||||
return Results{}, nil
|
||||
}
|
||||
}
|
||||
|
||||
err = filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
if path != c.Dir {
|
||||
_, err = os.Stat(filepath.Join(path, "go.mod"))
|
||||
if err == nil {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base := filepath.Base(path)
|
||||
|
||||
for _, ig := range DefaultIgnoredFolders {
|
||||
|
@ -128,11 +149,26 @@ func sourceFiles(pt paths.Path) ([]paths.Path, error) {
|
|||
if !fi.IsDir() {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
c, err := pkgs.Current()
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
err = filepath.Walk(fp, func(p string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
if p != c.Dir {
|
||||
_, err = os.Stat(filepath.Join(p, "go.mod"))
|
||||
if err == nil {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base := filepath.Base(p)
|
||||
|
||||
if base == "." {
|
||||
|
|
Loading…
Reference in New Issue