1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

Improve XDG Spec supporting (#1656)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Tony Soloveyv 2023-03-03 17:39:02 +03:00 committed by GitHub
parent d8ea1eb236
commit 5b7fb3fb22

View file

@ -12,6 +12,7 @@ import (
"strings" "strings"
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
"github.com/adrg/xdg"
"github.com/andreaskoch/go-fswatch" "github.com/andreaskoch/go-fswatch"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"github.com/mitchellh/go-homedir" "github.com/mitchellh/go-homedir"
@ -98,18 +99,21 @@ func configLocations() []string {
log.Fatal(err) log.Fatal(err)
} }
configFileName := ".actrc"
// reference: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html // reference: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
var actrcXdg string var actrcXdg string
if xdg, ok := os.LookupEnv("XDG_CONFIG_HOME"); ok && xdg != "" { for _, fileName := range []string{"act/actrc", configFileName} {
actrcXdg = filepath.Join(xdg, ".actrc") if foundConfig, err := xdg.SearchConfigFile(fileName); foundConfig != "" && err == nil {
} else { actrcXdg = foundConfig
actrcXdg = filepath.Join(home, ".config", ".actrc") break
}
} }
return []string{ return []string{
filepath.Join(home, ".actrc"), filepath.Join(home, configFileName),
actrcXdg, actrcXdg,
filepath.Join(".", ".actrc"), filepath.Join(".", configFileName),
} }
} }