mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
Rename CompileDir to CacheDir
This commit is contained in:
parent
b98f9f1efe
commit
19ba0321b0
3 changed files with 16 additions and 13 deletions
10
deno_dir.go
10
deno_dir.go
|
@ -12,6 +12,10 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
var DenoDir string
|
||||
var CacheDir string
|
||||
var SrcDir string
|
||||
|
||||
func SourceCodeHash(filename string, sourceCodeBuf []byte) string {
|
||||
h := md5.New()
|
||||
h.Write([]byte(filename))
|
||||
|
@ -21,7 +25,7 @@ func SourceCodeHash(filename string, sourceCodeBuf []byte) string {
|
|||
|
||||
func CacheFileName(filename string, sourceCodeBuf []byte) string {
|
||||
cacheKey := SourceCodeHash(filename, sourceCodeBuf)
|
||||
return path.Join(CompileDir, cacheKey+".js")
|
||||
return path.Join(CacheDir, cacheKey+".js")
|
||||
}
|
||||
|
||||
// Fetches a remoteUrl but also caches it to the localFilename.
|
||||
|
@ -87,8 +91,8 @@ func UserHomeDir() string {
|
|||
|
||||
func createDirs() {
|
||||
DenoDir = path.Join(UserHomeDir(), ".deno")
|
||||
CompileDir = path.Join(DenoDir, "compile")
|
||||
err := os.MkdirAll(CompileDir, 0700)
|
||||
CacheDir = path.Join(DenoDir, "cache")
|
||||
err := os.MkdirAll(CacheDir, 0700)
|
||||
check(err)
|
||||
SrcDir = path.Join(DenoDir, "src")
|
||||
err = os.MkdirAll(SrcDir, 0700)
|
||||
|
|
|
@ -5,16 +5,16 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func SetCompileDirForTest(prefix string) {
|
||||
func SetCacheDirForTest(prefix string) {
|
||||
dir, err := ioutil.TempDir("", prefix)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
CompileDir = dir
|
||||
CacheDir = dir
|
||||
}
|
||||
|
||||
func TestLoadOutputCodeCache(t *testing.T) {
|
||||
SetCompileDirForTest("TestLoadOutputCodeCache")
|
||||
SetCacheDirForTest("TestLoadOutputCodeCache")
|
||||
|
||||
filename := "Hello.ts"
|
||||
sourceCodeBuf := []byte("1+2")
|
||||
|
|
13
main.go
13
main.go
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/ry/v8worker2"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -15,22 +14,17 @@ var flagV8Options = flag.Bool("v8-options", false, "Print V8 command line option
|
|||
var flagDebug = flag.Bool("debug", false, "Enable debug output.")
|
||||
var flagGoProf = flag.String("goprof", "", "Write golang cpu profile to file.")
|
||||
|
||||
var DenoDir string
|
||||
var CompileDir string
|
||||
var SrcDir string
|
||||
|
||||
func stringAsset(path string) string {
|
||||
data, err := Asset("dist/" + path)
|
||||
check(err)
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func main() {
|
||||
func FlagsParse() []string {
|
||||
flag.Parse()
|
||||
args := flag.Args()
|
||||
if *flagV8Options {
|
||||
args = append(args, "--help")
|
||||
fmt.Println(args)
|
||||
}
|
||||
args = v8worker2.SetFlags(args)
|
||||
|
||||
|
@ -38,6 +32,11 @@ func main() {
|
|||
if !*flagDebug {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
func main() {
|
||||
args := FlagsParse()
|
||||
|
||||
// Maybe start Golang CPU profiler.
|
||||
// Use --prof for profiling JS.
|
||||
|
|
Loading…
Reference in a new issue