diff --git a/main.go b/main.go index 2c669e322f..32f011e917 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 59c24ccdff..44ec2ba9c2 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 similarity index 100% rename from main_test.go rename to os_test.go