@@ -21,37 +21,11 @@ function Normalize-Config {
2121
2222 switch ($ext ) {
2323 { $_ -in @ (' yaml' , ' yml' ) } {
24- # For YAML files, preserve the structure and sort within each section
25- $content = Get-Content $file - Raw
26-
27- # Extract sections using regex
28- $runtimesMatch = [regex ]::Match($content , " runtimes:([\s\S]*?)tools:" )
29- $toolsMatch = [regex ]::Match($content , " tools:([\s\S]*?)$" )
30-
31- if ($runtimesMatch.Success -and $toolsMatch.Success ) {
32- # Extract and sort runtimes
33- $runtimes = $runtimesMatch.Groups [1 ].Value -split " `n " |
34- Where-Object { $_ -match " ^\s*-\s*" } |
35- Sort-Object |
36- ForEach-Object { $_.Trim () }
37-
38- # Extract and sort tools
39- $tools = $toolsMatch.Groups [1 ].Value -split " `n " |
40- Where-Object { $_ -match " ^\s*-\s*" } |
41- Sort-Object |
42- ForEach-Object { $_.Trim () }
43-
44- # Return normalized content
45- @ (
46- " runtimes:"
47- $runtimes | ForEach-Object { " $_ " }
48- " tools:"
49- $tools | ForEach-Object { " $_ " }
50- )
51- } else {
52- Write-Error " Failed to parse YAML structure in $file "
53- exit 1
54- }
24+ # For YAML files, just sort the lines
25+ Get-Content $file |
26+ Where-Object { $_ -match ' \S' } | # Skip empty lines
27+ Sort-Object |
28+ ForEach-Object { $_.Trim () }
5529 }
5630 { $_ -in @ (' rc' , ' conf' , ' ini' , ' xml' ) } {
5731 Get-Content $file | ForEach-Object {
0 commit comments