mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-19 06:19:27 +00:00
Check source directroy for assets as last resort
This commit is contained in:
parent
e235b57234
commit
d90b71bc55
1 changed files with 10 additions and 2 deletions
|
|
@ -15,11 +15,13 @@ import (
|
||||||
|
|
||||||
func DefaultAssetPath() string {
|
func DefaultAssetPath() string {
|
||||||
var assetPath string
|
var assetPath string
|
||||||
|
pwd, _ := os.Getwd()
|
||||||
|
srcdir := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist")
|
||||||
|
|
||||||
// If the current working directory is the go-ethereum dir
|
// If the current working directory is the go-ethereum dir
|
||||||
// assume a debug build and use the source directory as
|
// assume a debug build and use the source directory as
|
||||||
// asset directory.
|
// asset directory.
|
||||||
pwd, _ := os.Getwd()
|
if pwd == srcdir {
|
||||||
if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist") {
|
|
||||||
assetPath = path.Join(pwd, "assets")
|
assetPath = path.Join(pwd, "assets")
|
||||||
} else {
|
} else {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
|
|
@ -34,6 +36,12 @@ func DefaultAssetPath() string {
|
||||||
default:
|
default:
|
||||||
assetPath = "."
|
assetPath = "."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the assetPath exists. If not, try the source directory
|
||||||
|
// This happens when binary is run from outside cmd/mist directory
|
||||||
|
if _, err := os.Stat(assetPath); os.IsNotExist(err) {
|
||||||
|
assetPath = path.Join(srcdir, "assets")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return assetPath
|
return assetPath
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue