mirror of https://github.com/markbates/pkger.git
fix pkger error if a project contains a .go directory #76
This commit is contained in:
parent
c9b56cd758
commit
5d81ba66cb
|
@ -108,9 +108,12 @@ func (p *Parser) ParseDir(abs string, mode parser.Mode) ([]*ParsedSource, error)
|
||||||
return nil, fmt.Errorf("%s: here.Parse failed %s", err, abs)
|
return nil, fmt.Errorf("%s: here.Parse failed %s", err, abs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fset := token.NewFileSet()
|
filter := func(f os.FileInfo) bool {
|
||||||
|
return !f.IsDir()
|
||||||
|
}
|
||||||
|
|
||||||
pkgs, err := parser.ParseDir(fset, abs, nil, 0)
|
fset := token.NewFileSet()
|
||||||
|
pkgs, err := parser.ParseDir(fset, abs, filter, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%s: ParseDir failed %s", err, abs)
|
return nil, fmt.Errorf("%s: ParseDir failed %s", err, abs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,27 @@ func Test_Parser_Ref_Include(t *testing.T) {
|
||||||
r.Equal(26, l)
|
r.Equal(26, l)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Parser_dotGo_Directory(t *testing.T) {
|
||||||
|
r := require.New(t)
|
||||||
|
|
||||||
|
ref, err := pkgtest.NewRef()
|
||||||
|
r.NoError(err)
|
||||||
|
defer os.RemoveAll(ref.Dir)
|
||||||
|
|
||||||
|
err = os.Mkdir(filepath.Join(ref.Dir, ".go"), 0755)
|
||||||
|
r.NoError(err)
|
||||||
|
|
||||||
|
disk, err := stdos.New(ref.Info)
|
||||||
|
r.NoError(err)
|
||||||
|
|
||||||
|
_, err = pkgtest.LoadFiles("/", ref, disk)
|
||||||
|
r.NoError(err)
|
||||||
|
|
||||||
|
res, err := Parse(ref.Info)
|
||||||
|
r.NoError(err)
|
||||||
|
r.Equal(11, len(res))
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Parser_Example_HTTP(t *testing.T) {
|
func Test_Parser_Example_HTTP(t *testing.T) {
|
||||||
r := require.New(t)
|
r := require.New(t)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue