@@ -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,36 +404,54 @@ 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 () {
417
417
b , err = io .ReadAll (os .Stdin )
418
418
if err != nil {
419
419
return nil , err
420
420
}
421
+
422
+ configs = append (configs , types.ConfigFile {
423
+ Filename : "-" ,
424
+ Content : b ,
425
+ Config : nil ,
426
+ })
421
427
} else {
422
428
f , err := filepath .Abs (c .Filename )
423
429
if err != nil {
424
430
return nil , err
425
431
}
426
- b , err = os .ReadFile (f )
432
+
433
+ matches , err := filepath .Glob (f )
427
434
if err != nil {
428
435
return nil , err
429
436
}
437
+
438
+ slices .Sort (matches )
439
+
440
+ for _ , match := range matches {
441
+ b , err = os .ReadFile (match )
442
+ if err != nil {
443
+ return nil , err
444
+ }
445
+
446
+ configs = append (configs , types.ConfigFile {
447
+ Filename : match ,
448
+ Content : b ,
449
+ Config : nil ,
450
+ })
451
+ }
430
452
}
431
- configs [i ] = b
432
- }
433
- for i , c := range configs {
434
- config .ConfigFiles [i ].Content = c
435
453
}
454
+ config .ConfigFiles = configs
436
455
return config , nil
437
456
}
438
457
@@ -476,7 +495,7 @@ func (o *ProjectOptions) prepare(ctx context.Context) (*types.ConfigDetails, err
476
495
return & types.ConfigDetails {}, err
477
496
}
478
497
479
- configDetails , err := o .ReadConfigFiles (ctx , defaultDir , o )
498
+ configDetails , err := o .ReadConfigFiles (ctx , defaultDir )
480
499
if err != nil {
481
500
return configDetails , err
482
501
}
0 commit comments