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

Use path.Join instead of + (#143)

Towards windows support.
This commit is contained in:
chainhelen 2018-06-11 21:08:22 +08:00 committed by Ryan Dahl
parent 0132a4d11d
commit 1e5b25091c
3 changed files with 5 additions and 4 deletions

View file

@ -87,7 +87,7 @@ func LoadOutputCodeCache(filename string, sourceCodeBuf []byte) (
func UserHomeDir() string { func UserHomeDir() string {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") home := path.Join(os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH"))
if home == "" { if home == "" {
home = os.Getenv("USERPROFILE") home = os.Getenv("USERPROFILE")
} }

View file

@ -6,6 +6,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"path"
"runtime/pprof" "runtime/pprof"
"github.com/ry/v8worker2" "github.com/ry/v8worker2"
@ -38,8 +39,8 @@ func setPerms() {
Perms.Net = *flagAllowNet Perms.Net = *flagAllowNet
} }
func stringAsset(path string) string { func stringAsset(filename string) string {
data, err := Asset("dist/" + path) data, err := Asset(path.Join("dist", filename))
check(err) check(err)
return string(data) return string(data)
} }

2
os.go
View file

@ -123,7 +123,7 @@ func HandleCodeFetch(moduleSpecifier string, containingFile string) (out []byte)
sourceCodeBuf, err = FetchRemoteSource(moduleName, filename) sourceCodeBuf, err = FetchRemoteSource(moduleName, filename)
} else if strings.HasPrefix(moduleName, assetPrefix) { } else if strings.HasPrefix(moduleName, assetPrefix) {
f := strings.TrimPrefix(moduleName, assetPrefix) f := strings.TrimPrefix(moduleName, assetPrefix)
sourceCodeBuf, err = Asset("dist/" + f) sourceCodeBuf, err = Asset(path.Join("dist", f))
if err != nil { if err != nil {
logDebug("%s Asset doesn't exist. Return without error", moduleName) logDebug("%s Asset doesn't exist. Return without error", moduleName)
err = nil err = nil