@@ -21,6 +21,7 @@ import (
21
21
"io"
22
22
"os"
23
23
"path/filepath"
24
+ "slices"
24
25
"strconv"
25
26
"strings"
26
27
@@ -403,14 +404,13 @@ func (o *ProjectOptions) GetWorkingDir() (string, error) {
403
404
}
404
405
405
406
// ReadConfigFiles reads ConfigFiles and populates the content field
406
- func (o * ProjectOptions ) ReadConfigFiles (ctx context.Context , workingDir string , options * ProjectOptions ) (* types.ConfigDetails , error ) {
407
- config , err := loader .LoadConfigFiles (ctx , options .ConfigPaths , workingDir , options .loadOptions ... )
407
+ func (o * ProjectOptions ) ReadConfigFiles (ctx context.Context , workingDir string ) (* types.ConfigDetails , error ) {
408
+ config , err := loader .LoadConfigFiles (ctx , o .ConfigPaths , workingDir , o .loadOptions ... )
408
409
if err != nil {
409
410
return nil , err
410
411
}
411
- configs := make ([][]byte , len (config .ConfigFiles ))
412
-
413
- for i , c := range config .ConfigFiles {
412
+ configs := make ([]types.ConfigFile , 0 , len (config .ConfigFiles ))
413
+ for _ , c := range config .ConfigFiles {
414
414
var err error
415
415
var b []byte
416
416
if c .IsStdin () {
@@ -423,16 +423,29 @@ func (o *ProjectOptions) ReadConfigFiles(ctx context.Context, workingDir string,
423
423
if err != nil {
424
424
return nil , err
425
425
}
426
- b , err = os .ReadFile (f )
426
+
427
+ matches , err := filepath .Glob (f )
427
428
if err != nil {
428
429
return nil , err
429
430
}
431
+
432
+ slices .Sort (matches )
433
+
434
+ for _ , match := range matches {
435
+ b , err = os .ReadFile (match )
436
+ if err != nil {
437
+ return nil , err
438
+ }
439
+
440
+ configs = append (configs , types.ConfigFile {
441
+ Filename : match ,
442
+ Content : b ,
443
+ Config : nil ,
444
+ })
445
+ }
430
446
}
431
- configs [i ] = b
432
- }
433
- for i , c := range configs {
434
- config .ConfigFiles [i ].Content = c
435
447
}
448
+ config .ConfigFiles = configs
436
449
return config , nil
437
450
}
438
451
@@ -476,7 +489,7 @@ func (o *ProjectOptions) prepare(ctx context.Context) (*types.ConfigDetails, err
476
489
return & types.ConfigDetails {}, err
477
490
}
478
491
479
- configDetails , err := o .ReadConfigFiles (ctx , defaultDir , o )
492
+ configDetails , err := o .ReadConfigFiles (ctx , defaultDir )
480
493
if err != nil {
481
494
return configDetails , err
482
495
}
0 commit comments