diff options
author | Nick Flueckiger <nick.flueckiger@renuo.ch> | 2020-11-22 14:51:48 +0100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 10:42:38 +1100 |
commit | 7513bfb13a48c566e9ab0c31e259ea73d562c292 (patch) | |
tree | 6354fbc6fee345121aeddfcdd9b5e90afaee0622 /pkg/config/app_config.go | |
parent | 1f27002b8471592e163b0ccbe1dfce4ecd3245f9 (diff) |
Implement suggestions
Diffstat (limited to 'pkg/config/app_config.go')
-rw-r--r-- | pkg/config/app_config.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 5e0a08316..86801781b 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -81,28 +81,26 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg return appConfig, nil } -func SelectDefaultConfiguration() string { - legacyConfigDirectory := ConfigDir("jesseduffield") +func ConfigDir() string { + legacyConfigDirectory := configDirForVendor("jesseduffield") if _, err := os.Stat(legacyConfigDirectory); !os.IsNotExist(err) { return legacyConfigDirectory } - configDirectory := ConfigDir("") + configDirectory := configDirForVendor("") return configDirectory } -func ConfigDir(vendor string) string { +func configDirForVendor(vendor string) string { envConfigDir := os.Getenv("CONFIG_DIR") if envConfigDir != "" { return envConfigDir } - // chucking my name there is not for vanity purposes, the xdg spec (and that - // function) requires a vendor name. May as well line up with github configDirs := xdg.New(vendor, "lazygit") return configDirs.ConfigHome() } func findOrCreateConfigDir() (string, error) { - folder := SelectDefaultConfiguration() + folder := ConfigDir() err := os.MkdirAll(folder, 0755) if err != nil { return "", err |