Skip to content

Commit

Permalink
fix: include other files in mempkg
Browse files Browse the repository at this point in the history
Signed-off-by: Norman <norman@samourai.coop>
  • Loading branch information
n0izn0iz committed Feb 3, 2025
1 parent 98ccddd commit 52bcc43
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gnovm/pkg/packages/analyze_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func readPkgDir(pkgDir string, importPath string, fset *token.FileSet) *Package

base := entry.Name()

if !strings.HasSuffix(base, ".gno") {
if !strings.HasSuffix(base, ".gno") && base != "LICENSE" && base != "README.md" {
continue
}

Expand Down
6 changes: 2 additions & 4 deletions gnovm/pkg/packages/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path/filepath"
"slices"
"sort"
"strings"

"github.com/gnolang/gno/gnovm"
"github.com/gnolang/gno/gnovm/pkg/gnoenv"
Expand Down Expand Up @@ -227,12 +226,11 @@ func listDepsRecursive(rootTarget *Package, target *Package, pkgs PackagesMap, d
}

func (p *Package) MemPkg() (*gnovm.MemPackage, error) {
// XXX: use gnolang.ReadMemPackageFromList

files := []*gnovm.MemFile{}
for _, cat := range p.Files {
for _, f := range cat {
if !strings.HasSuffix(f, ".gno") {
continue
}
body, err := os.ReadFile(filepath.Join(p.Dir, f))
if err != nil {
return nil, err
Expand Down
3 changes: 0 additions & 3 deletions gnovm/pkg/packages/pkglist.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package packages
import (
"errors"
"fmt"
"os"
"slices"

"github.com/davecgh/go-spew/spew"
"github.com/gnolang/gno/gnovm"
"github.com/gnolang/gno/gnovm/pkg/gnolang"
)
Expand Down Expand Up @@ -137,7 +135,6 @@ func (pl PkgList) GetMemPackage(pkgPath string) *gnovm.MemPackage {
}
memPkg, err := pkg.MemPkg()
if err != nil {
spew.Fdump(os.Stderr, "get err", err)
panic(err)
}
return memPkg
Expand Down
8 changes: 4 additions & 4 deletions gnovm/pkg/packages/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type Package struct {
Name string `json:",omitempty"` // package name
Root string `json:",omitempty"` // Gno root, Gno path dir, or module root dir containing this package
ModPath string
Match []string `json:",omitempty"` // command-line patterns matching this package
Errors []*Error `json:",omitempty"` // error loading this package (not dependencies)
Draft bool
Files FilesMap
Match []string `json:",omitempty"` // command-line patterns matching this package
Errors []*Error `json:",omitempty"` // error loading this package (not dependencies)
Draft bool `json:",omitempty"`
Files FilesMap `json:",omitempty"`
Imports map[FileKind][]string `json:",omitempty"` // import paths used by this package
Deps []string `json:",omitempty"` // all (recursively) imported dependencies

Expand Down

0 comments on commit 52bcc43

Please sign in to comment.