mirror of
https://github.com/google/go-jsonnet.git
synced 2025-09-28 17:01:02 +02:00
fix FileImporter not work on windows
This commit is contained in:
parent
c17729a921
commit
b835910677
@ -20,7 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/google/go-jsonnet/ast"
|
"github.com/google/go-jsonnet/ast"
|
||||||
@ -232,10 +232,10 @@ func (importer *FileImporter) tryPath(dir, importedPath string) (found bool, con
|
|||||||
importer.fsCache = make(map[string]*fsCacheEntry)
|
importer.fsCache = make(map[string]*fsCacheEntry)
|
||||||
}
|
}
|
||||||
var absPath string
|
var absPath string
|
||||||
if path.IsAbs(importedPath) {
|
if filepath.IsAbs(importedPath) {
|
||||||
absPath = importedPath
|
absPath = importedPath
|
||||||
} else {
|
} else {
|
||||||
absPath = path.Join(dir, importedPath)
|
absPath = filepath.Join(dir, importedPath)
|
||||||
}
|
}
|
||||||
var entry *fsCacheEntry
|
var entry *fsCacheEntry
|
||||||
if cacheEntry, isCached := importer.fsCache[absPath]; isCached {
|
if cacheEntry, isCached := importer.fsCache[absPath]; isCached {
|
||||||
@ -268,7 +268,7 @@ func (importer *FileImporter) Import(importedFrom, importedPath string) (content
|
|||||||
// in the importer.
|
// in the importer.
|
||||||
// We need to relativize the paths in the error formatter, so that the stack traces
|
// We need to relativize the paths in the error formatter, so that the stack traces
|
||||||
// don't have ugly absolute paths (less readable and messy with golden tests).
|
// don't have ugly absolute paths (less readable and messy with golden tests).
|
||||||
dir, _ := path.Split(importedFrom)
|
dir, _ := filepath.Split(importedFrom)
|
||||||
found, content, foundHere, err := importer.tryPath(dir, importedPath)
|
found, content, foundHere, err := importer.tryPath(dir, importedPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Contents{}, "", err
|
return Contents{}, "", err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user