From 1e5b25091ce634d180129a0b156aa24a7e9a5327 Mon Sep 17 00:00:00 2001 From: chainhelen Date: Mon, 11 Jun 2018 21:08:22 +0800 Subject: [PATCH] Use path.Join instead of + (#143) Towards windows support. --- deno_dir.go | 2 +- main.go | 5 +++-- os.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/deno_dir.go b/deno_dir.go index 2df1f74b4b..1fac10831a 100644 --- a/deno_dir.go +++ b/deno_dir.go @@ -87,7 +87,7 @@ func LoadOutputCodeCache(filename string, sourceCodeBuf []byte) ( func UserHomeDir() string { if runtime.GOOS == "windows" { - home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") + home := path.Join(os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH")) if home == "" { home = os.Getenv("USERPROFILE") } diff --git a/main.go b/main.go index 37cfd022d4..c9923bd770 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "flag" "fmt" "os" + "path" "runtime/pprof" "github.com/ry/v8worker2" @@ -38,8 +39,8 @@ func setPerms() { Perms.Net = *flagAllowNet } -func stringAsset(path string) string { - data, err := Asset("dist/" + path) +func stringAsset(filename string) string { + data, err := Asset(path.Join("dist", filename)) check(err) return string(data) } diff --git a/os.go b/os.go index 85ca8f0927..5cbb0f5ec9 100644 --- a/os.go +++ b/os.go @@ -123,7 +123,7 @@ func HandleCodeFetch(moduleSpecifier string, containingFile string) (out []byte) sourceCodeBuf, err = FetchRemoteSource(moduleName, filename) } else if strings.HasPrefix(moduleName, assetPrefix) { f := strings.TrimPrefix(moduleName, assetPrefix) - sourceCodeBuf, err = Asset("dist/" + f) + sourceCodeBuf, err = Asset(path.Join("dist", f)) if err != nil { logDebug("%s Asset doesn't exist. Return without error", moduleName) err = nil