feat(eval): handle fully qualified imports

Now also supports github.com/sh0rez/docsonnet/doc-util

Fixes #4
This commit is contained in:
sh0rez 2020-08-17 09:25:33 +02:00
parent 2f9dcb2d21
commit 3e1757637e
No known key found for this signature in database
GPG key ID: 87C71DF9F8181FF1

View file

@ -94,9 +94,16 @@ func newImporter(paths []string) (*importer, error) {
}, nil }, nil
} }
var docUtilPaths = []string{
"doc-util/main.libsonnet",
"github.com/sh0rez/docsonnet/doc-util/main.libsonnet",
}
func (i *importer) Import(importedFrom, importedPath string) (contents jsonnet.Contents, foundAt string, err error) { func (i *importer) Import(importedFrom, importedPath string) (contents jsonnet.Contents, foundAt string, err error) {
if importedPath == "doc-util/main.libsonnet" { for _, p := range docUtilPaths {
return i.util, "<internal>", nil if importedPath == p {
return i.util, "<internal>", nil
}
} }
return i.fi.Import(importedFrom, importedPath) return i.fi.Import(importedFrom, importedPath)