1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

Move ResolveModule to os.go

This commit is contained in:
Ryan Dahl 2018-05-23 11:09:38 -04:00
parent 10c198fffd
commit 08b327bf3a
3 changed files with 22 additions and 22 deletions

22
main.go
View file

@ -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)

22
os.go
View file

@ -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{}