Skip to content

Commit d6615a6

Browse files
committed
Use concurrentbag
1 parent 5ae6f16 commit d6615a6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
$psPaths = $env:PSModulePath -split [System.IO.Path]::PathSeparator | Where-Object { $_ -notmatch 'WindowsPowerShell' }
2-
$manifests = [System.Collections.Generic.List[hashtable]]::new()
2+
3+
$m = [System.Collections.Concurrent.ConcurrentBag[hashtable]]::new()
34

45
$psPaths | ForEach-Object -Parallel {
5-
$queue = $using:manifests
6-
$files = Get-ChildItem -Path $_ -Recurse -File -Include '*.dsc.resource.json', '*.dsc.resource.yaml', '*.dsc.resource.yml' -ErrorAction Ignore
6+
$queue = $using:m
7+
$files = Get-ChildItem -Path $_ -Recurse -File -Filter '*.dsc.resource.*' -ErrorAction Ignore |
8+
Where-Object -Property Extension -In @('.json', '.yaml', '.yml')
9+
710
foreach ($file in $files) {
8-
$m = @{ manifestPath = $file.FullName }
9-
$queue.Add($m)
11+
$queue.Add(@{ manifestPath = $file.FullName })
1012
}
1113
} -ThrottleLimit 10
1214

13-
$manifests | ConvertTo-Json -Compress
15+
@($m) | ConvertTo-Json -Compress

0 commit comments

Comments
 (0)