1// +build gopherjsdev
2
3package gopherjspkg
4
5import (
6	"go/build"
7	"log"
8	"net/http"
9	"os"
10	pathpkg "path"
11
12	"github.com/shurcooL/httpfs/filter"
13)
14
15// FS is a virtual filesystem that contains core GopherJS packages.
16var FS = filter.Keep(
17	http.Dir(importPathToDir("github.com/gopherjs/gopherjs")),
18	func(path string, fi os.FileInfo) bool {
19		return path == "/" ||
20			path == "/js" || (pathpkg.Dir(path) == "/js" && !fi.IsDir()) ||
21			path == "/nosync" || (pathpkg.Dir(path) == "/nosync" && !fi.IsDir())
22	},
23)
24
25func importPathToDir(importPath string) string {
26	p, err := build.Import(importPath, "", build.FindOnly)
27	if err != nil {
28		log.Fatalln(err)
29	}
30	return p.Dir
31}
32