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

privatize some methods

This commit is contained in:
Ryan Dahl 2018-05-19 05:56:02 -04:00
parent 258aa56532
commit ca8eb1d421
3 changed files with 6 additions and 6 deletions

View file

@ -28,7 +28,7 @@ func CacheFileName(filename string, sourceCodeBuf []byte) string {
// Fetches a remoteUrl but also caches it to the localFilename.
func FetchRemoteSource(remoteUrl string, localFilename string) ([]byte, error) {
//println("FetchRemoteSource", remoteUrl)
Assert(strings.HasPrefix(localFilename, SrcDir), localFilename)
assert(strings.HasPrefix(localFilename, SrcDir), localFilename)
var sourceReader io.Reader
file, err := os.Open(localFilename)

View file

@ -36,7 +36,7 @@ func recv(buf []byte) []byte {
}
func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out []byte) {
Assert(moduleSpecifier != "", "moduleSpecifier shouldn't be empty")
assert(moduleSpecifier != "", "moduleSpecifier shouldn't be empty")
res := &Msg{}
var sourceCodeBuf []byte
var err error
@ -57,13 +57,13 @@ func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out [
//println("HandleSourceCodeFetch", "moduleSpecifier", moduleSpecifier,
// "containingFile", containingFile, "filename", filename)
if IsRemote(moduleName) {
if isRemote(moduleName) {
sourceCodeBuf, err = FetchRemoteSource(moduleName, filename)
} else if strings.HasPrefix(moduleName, assetPrefix) {
f := strings.TrimPrefix(moduleName, assetPrefix)
sourceCodeBuf, err = Asset("dist/" + f)
} else {
Assert(moduleName == filename,
assert(moduleName == filename,
"if a module isn't remote, it should have the same filename")
sourceCodeBuf, err = ioutil.ReadFile(moduleName)
}

View file

@ -4,13 +4,13 @@ import (
"net/url"
)
func Assert(cond bool, msg string) {
func assert(cond bool, msg string) {
if !cond {
panic(msg)
}
}
func IsRemote(filename string) bool {
func isRemote(filename string) bool {
u, err := url.Parse(filename)
check(err)
return u.IsAbs()