Skip to content

Commit

Permalink
Merge pull request #111 from transifex/fix_home_dir
Browse files Browse the repository at this point in the history
Get home directory from environment variable
  • Loading branch information
kbairak authored Oct 18, 2022
2 parents 39a6452 + 990e28a commit a4b6022
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/txlib/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,13 @@ func rootConfigsEqual(left, right *RootConfig) bool {
}

func GetRootPath() (string, error) {
usr, err := user.Current()
if err != nil {
return "", err
homeDir := os.Getenv("HOME")
if homeDir == "" {
usr, err := user.Current()
if err != nil {
return "", err
}
homeDir = usr.HomeDir
}
return filepath.Join(usr.HomeDir, ".transifexrc"), nil
return filepath.Join(homeDir, ".transifexrc"), nil
}

0 comments on commit a4b6022

Please sign in to comment.