summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go22
-rw-r--r--os.go22
-rw-r--r--os_test.go (renamed from main_test.go)0
3 files changed, 22 insertions, 22 deletions
diff --git a/main.go b/main.go
index 2c669e322..32f011e91 100644
--- a/main.go
+++ b/main.go
@@ -6,9 +6,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/ry/v8worker2"
"log"
- "net/url"
"os"
- "path"
"runtime/pprof"
)
@@ -21,26 +19,6 @@ var DenoDir string
var CompileDir string
var SrcDir string
-func ResolveModule(moduleSpecifier string, containingFile string) (
- moduleName string, filename string, err error) {
- moduleUrl, err := url.Parse(moduleSpecifier)
- if err != nil {
- return
- }
- baseUrl, err := url.Parse(containingFile)
- if err != nil {
- return
- }
- resolved := baseUrl.ResolveReference(moduleUrl)
- moduleName = resolved.String()
- if moduleUrl.IsAbs() {
- filename = path.Join(SrcDir, resolved.Host, resolved.Path)
- } else {
- filename = resolved.Path
- }
- return
-}
-
func stringAsset(path string) string {
data, err := Asset("dist/" + path)
check(err)
diff --git a/os.go b/os.go
index 59c24ccdf..44ec2ba9c 100644
--- a/os.go
+++ b/os.go
@@ -3,7 +3,9 @@ package main
import (
"github.com/golang/protobuf/proto"
"io/ioutil"
+ "net/url"
"os"
+ "path"
"strings"
)
@@ -31,6 +33,26 @@ func InitOS() {
})
}
+func ResolveModule(moduleSpecifier string, containingFile string) (
+ moduleName string, filename string, err error) {
+ moduleUrl, err := url.Parse(moduleSpecifier)
+ if err != nil {
+ return
+ }
+ baseUrl, err := url.Parse(containingFile)
+ if err != nil {
+ return
+ }
+ resolved := baseUrl.ResolveReference(moduleUrl)
+ moduleName = resolved.String()
+ if moduleUrl.IsAbs() {
+ filename = path.Join(SrcDir, resolved.Host, resolved.Path)
+ } else {
+ filename = resolved.Path
+ }
+ return
+}
+
func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out []byte) {
assert(moduleSpecifier != "", "moduleSpecifier shouldn't be empty")
res := &Msg{}
diff --git a/main_test.go b/os_test.go
index ac94b5a3c..ac94b5a3c 100644
--- a/main_test.go
+++ b/os_test.go