mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -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"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var DenoDir string
|
||||||
|
var CacheDir string
|
||||||
|
var SrcDir string
|
||||||
|
|
||||||
func SourceCodeHash(filename string, sourceCodeBuf []byte) string {
|
func SourceCodeHash(filename string, sourceCodeBuf []byte) string {
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
h.Write([]byte(filename))
|
h.Write([]byte(filename))
|
||||||
|
@ -21,7 +25,7 @@ func SourceCodeHash(filename string, sourceCodeBuf []byte) string {
|
||||||
|
|
||||||
func CacheFileName(filename string, sourceCodeBuf []byte) string {
|
func CacheFileName(filename string, sourceCodeBuf []byte) string {
|
||||||
cacheKey := SourceCodeHash(filename, sourceCodeBuf)
|
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.
|
// Fetches a remoteUrl but also caches it to the localFilename.
|
||||||
|
@ -87,8 +91,8 @@ func UserHomeDir() string {
|
||||||
|
|
||||||
func createDirs() {
|
func createDirs() {
|
||||||
DenoDir = path.Join(UserHomeDir(), ".deno")
|
DenoDir = path.Join(UserHomeDir(), ".deno")
|
||||||
CompileDir = path.Join(DenoDir, "compile")
|
CacheDir = path.Join(DenoDir, "cache")
|
||||||
err := os.MkdirAll(CompileDir, 0700)
|
err := os.MkdirAll(CacheDir, 0700)
|
||||||
check(err)
|
check(err)
|
||||||
SrcDir = path.Join(DenoDir, "src")
|
SrcDir = path.Join(DenoDir, "src")
|
||||||
err = os.MkdirAll(SrcDir, 0700)
|
err = os.MkdirAll(SrcDir, 0700)
|
||||||
|
|
|
@ -5,16 +5,16 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetCompileDirForTest(prefix string) {
|
func SetCacheDirForTest(prefix string) {
|
||||||
dir, err := ioutil.TempDir("", prefix)
|
dir, err := ioutil.TempDir("", prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
CompileDir = dir
|
CacheDir = dir
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadOutputCodeCache(t *testing.T) {
|
func TestLoadOutputCodeCache(t *testing.T) {
|
||||||
SetCompileDirForTest("TestLoadOutputCodeCache")
|
SetCacheDirForTest("TestLoadOutputCodeCache")
|
||||||
|
|
||||||
filename := "Hello.ts"
|
filename := "Hello.ts"
|
||||||
sourceCodeBuf := []byte("1+2")
|
sourceCodeBuf := []byte("1+2")
|
||||||
|
|
13
main.go
13
main.go
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"github.com/ry/v8worker2"
|
"github.com/ry/v8worker2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"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 flagDebug = flag.Bool("debug", false, "Enable debug output.")
|
||||||
var flagGoProf = flag.String("goprof", "", "Write golang cpu profile to file.")
|
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 {
|
func stringAsset(path string) string {
|
||||||
data, err := Asset("dist/" + path)
|
data, err := Asset("dist/" + path)
|
||||||
check(err)
|
check(err)
|
||||||
return string(data)
|
return string(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func FlagsParse() []string {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
args := flag.Args()
|
args := flag.Args()
|
||||||
if *flagV8Options {
|
if *flagV8Options {
|
||||||
args = append(args, "--help")
|
args = append(args, "--help")
|
||||||
fmt.Println(args)
|
|
||||||
}
|
}
|
||||||
args = v8worker2.SetFlags(args)
|
args = v8worker2.SetFlags(args)
|
||||||
|
|
||||||
|
@ -38,6 +32,11 @@ func main() {
|
||||||
if !*flagDebug {
|
if !*flagDebug {
|
||||||
log.SetOutput(ioutil.Discard)
|
log.SetOutput(ioutil.Discard)
|
||||||
}
|
}
|
||||||
|
return args
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
args := FlagsParse()
|
||||||
|
|
||||||
// Maybe start Golang CPU profiler.
|
// Maybe start Golang CPU profiler.
|
||||||
// Use --prof for profiling JS.
|
// Use --prof for profiling JS.
|
||||||
|
|
Loading…
Add table
Reference in a new issue