Skip to content

Commit

Permalink
use platform agnostic filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Aug 9, 2018
1 parent 1f5f80b commit 750445d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,21 @@ func homeDirectory() string {
return usr.HomeDir
}

func projectPath(path string) string {
gopath := os.Getenv("GOPATH")
return filepath.FromSlash(gopath + "/src/github.com/jesseduffield/lazygit/" + path)
}

func devLog(objects ...interface{}) {
localLog(color.FgWhite, homeDirectory()+"/go/src/github.com/jesseduffield/lazygit/development.log", objects...)
localLog(color.FgWhite, projectPath("development.log"), objects...)
}

func colorLog(colour color.Attribute, objects ...interface{}) {
localLog(colour, homeDirectory()+"/go/src/github.com/jesseduffield/lazygit/development.log", objects...)
localLog(colour, projectPath("development.log"), objects...)
}

func commandLog(objects ...interface{}) {
localLog(color.FgWhite, homeDirectory()+"/go/src/github.com/jesseduffield/lazygit/commands.log", objects...)
localLog(color.FgWhite, projectPath("commands.log"), objects...)
}

func localLog(colour color.Attribute, path string, objects ...interface{}) {
Expand Down Expand Up @@ -75,8 +80,7 @@ func navigateToRepoRootDirectory() {
// with `date` and `commit`. If this program has been opened directly via go,
// we will populate the `version` with VERSION in the lazygit root directory
func fallbackVersion() string {
gopath := os.Getenv("GOPATH")
path := filepath.FromSlash(gopath + "/src/github.com/jesseduffield/lazygit/VERSION")
path := projectPath("VERSION")
byteVersion, err := ioutil.ReadFile(path)
if err != nil {
return "unversioned"
Expand Down

0 comments on commit 750445d

Please sign in to comment.