-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-combine.ps1
42 lines (31 loc) · 980 Bytes
/
class-combine.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Install-Module -Name powershell-yaml
$runs = @{}
$files = Get-ChildItem .\per-class -Filter "*.yml"
$count = 0
$total = $files.Count
$files | ForEach-Object {
$run = $_.BaseName
$count += 1
$perc = $count * 100 / $total
Write-Progress "Combine" $run -PercentComplete $perc
$_ | Get-Content | ConvertFrom-Yaml | `
ForEach-Object {
$_ | ForEach-Object {
if ($_.filename -match "\\test\\") {
return
}
$class = $_.name
if ($runs.Keys -notcontains $class ) {
$runs[$class] = @{filename=$_.filename;allLines=$_.allLines;runs=@{}}
}
$runs[$class].runs[$run] = $_.lines.ToString()
}
}
}
Write-Progress "Combine" -Completed
$runs | ConvertTo-Yaml -Options DisableAliases | Set-Content "runs-all.yml"
$singles = $runs.Keys | Where-Object { $runs[$_].runs.Count -lt 2 }
foreach ($class in $singles) {
$runs.Remove($class)
}
$runs | ConvertTo-Yaml -Options DisableAliases | Set-Content "runs-many.yml"