summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/github.com/gopherjs/gopherjs/compiler/gopherjspkg/fs.go
blob: f6fb2622db0e8565ed98d3ab71245c78359bd95b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// +build gopherjsdev

package gopherjspkg

import (
	"go/build"
	"log"
	"net/http"
	"os"
	pathpkg "path"

	"github.com/shurcooL/httpfs/filter"
)

// FS is a virtual filesystem that contains core GopherJS packages.
var FS = filter.Keep(
	http.Dir(importPathToDir("github.com/gopherjs/gopherjs")),
	func(path string, fi os.FileInfo) bool {
		return path == "/" ||
			path == "/js" || (pathpkg.Dir(path) == "/js" && !fi.IsDir()) ||
			path == "/nosync" || (pathpkg.Dir(path) == "/nosync" && !fi.IsDir())
	},
)

func importPathToDir(importPath string) string {
	p, err := build.Import(importPath, "", build.FindOnly)
	if err != nil {
		log.Fatalln(err)
	}
	return p.Dir
}