mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-13 01:30:53 +02:00
use shibukawa/configdir package to follow xdg spec config directory structure
This commit is contained in:
@ -3,10 +3,9 @@ package config
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
|
"github.com/shibukawa/configdir"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -89,15 +88,20 @@ func LoadUserConfig() (*viper.Viper, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
v.SetConfigName("config")
|
v.SetConfigName("config")
|
||||||
configPath := homeDirectory() + "/lazygit/"
|
|
||||||
if _, err := os.Stat(filepath.FromSlash(configPath + "config.yaml")); !os.IsNotExist(err) {
|
// chucking my name there is not for vanity purposes, the xdg spec (and that
|
||||||
v.AddConfigPath(configPath)
|
// function) requires a vendor name. May as well line up with github
|
||||||
err = v.MergeInConfig()
|
configDirs := configdir.New("jesseduffield", "lazygit")
|
||||||
|
folder := configDirs.QueryFolderContainsFile("config.yml")
|
||||||
|
if folder != nil {
|
||||||
|
configData, err := folder.ReadFile("config.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err = v.MergeConfig(bytes.NewReader(configData)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user