@@ -107,24 +107,22 @@ func Execute(ctx context.Context, version string) {
107
107
}
108
108
}
109
109
110
- // Return locations where Act's config can be found in order : XDG spec, .actrc in HOME directory, .actrc in invocation directory
110
+ // Return locations where Act's config can be found in order: XDG spec, .actrc in HOME directory, .actrc in invocation directory
111
111
func configLocations () []string {
112
112
configFileName := ".actrc"
113
113
114
- // reference: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
115
- var actrcXdg string
116
- for _ , fileName := range []string {"act/actrc" , configFileName } {
117
- if foundConfig , err := xdg .SearchConfigFile (fileName ); foundConfig != "" && err == nil {
118
- actrcXdg = foundConfig
119
- break
120
- }
121
- }
114
+ homePath := filepath .Join (UserHomeDir , configFileName )
115
+ invocationPath := filepath .Join ("." , configFileName )
122
116
123
- return []string {
124
- actrcXdg ,
125
- filepath .Join (UserHomeDir , configFileName ),
126
- filepath .Join ("." , configFileName ),
117
+ // Though named xdg, adrg's lib support macOS and Windows config paths as well
118
+ // It also takes cares of creating the parent folder so we don't need to bother later
119
+ specPath , err := xdg .ConfigFile ("act/actrc" )
120
+ if err != nil {
121
+ specPath = homePath
127
122
}
123
+
124
+ // This order should be enforced since the survey part relies on it
125
+ return []string {specPath , homePath , invocationPath }
128
126
}
129
127
130
128
var commonSocketPaths = []string {
@@ -554,7 +552,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
554
552
}
555
553
}
556
554
if ! cfgFound && len (cfgLocations ) > 0 {
557
- // The first config location refers to the XDG spec one
555
+ // The first config location refers to the global config folder one
558
556
if err := defaultImageSurvey (cfgLocations [0 ]); err != nil {
559
557
log .Fatal (err )
560
558
}
0 commit comments