Skip to content

Commit

Permalink
Merge pull request #32 from v1nh1shungry/check-root-exists
Browse files Browse the repository at this point in the history
fix #31
  • Loading branch information
shilangyu authored Jan 25, 2023
2 parents 98f7d1b + b59f91d commit 6a4e826
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ func scoopHome() (res string) {
configHome = home + "\\.config"
}

path := configHome + "\\scoop\\config.json"
if content, err := os.ReadFile(path); err == nil {
configPath := configHome + "\\scoop\\config.json"
if content, err := os.ReadFile(configPath); err == nil {
var parser fastjson.Parser
config, _ := parser.ParseBytes(content)
res = string(config.GetStringBytes("root_path"))
} else {
}

// installing with default directory doesn't have `SCOOP`
// and `root_path` either
if res == "" {
res = home + "\\scoop"
}
}
Expand Down

0 comments on commit 6a4e826

Please sign in to comment.