File tree Expand file tree Collapse file tree 1 file changed +21
-18
lines changed
Expand file tree Collapse file tree 1 file changed +21
-18
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,25 @@ $AutoRestTempFolder | ForEach-Object {
9191 }
9292}
9393
94+ function Get-OpenFiles {
95+ param (
96+ [string ] $Path
97+ )
98+ $OpenFiles = @ ()
99+ $Files = Get-ChildItem - Path $Path - Recurse - Directory | Where-Object { $_.Name -match " autorest" }
100+ $Files | ForEach-Object {
101+ $File = $_
102+ try {
103+ $FileStream = $File.Open ([System.IO.FileMode ]::Open, [System.IO.FileAccess ]::ReadWrite, [System.IO.FileShare ]::None)
104+ $FileStream.Close ()
105+ }
106+ catch {
107+ $OpenFiles += $File.FullName
108+ }
109+ }
110+ return $OpenFiles
111+ }
112+
94113$Stopwatch = [system.diagnostics.stopwatch ]::StartNew()
95114$CpuCount = (Get-CimInstance Win32_Processor).NumberOfLogicalProcessors
96115$Throttle = [math ]::Min(4 , $cpuCount / 2 ) # Use half the CPU count but max 4
@@ -119,24 +138,8 @@ $ModuleToGenerate | ForEach-Object -Parallel {
119138 }
120139
121140
141+
122142} - ThrottleLimit $Throttle
123143$stopwatch.Stop ()
124- function Get-OpenFiles {
125- param (
126- [string ] $Path
127- )
128- $OpenFiles = @ ()
129- $Files = Get-ChildItem - Path $Path - Recurse - Directory | Where-Object { $_.Name -match " autorest" }
130- $Files | ForEach-Object {
131- $File = $_
132- try {
133- $FileStream = $File.Open ([System.IO.FileMode ]::Open, [System.IO.FileAccess ]::ReadWrite, [System.IO.FileShare ]::None)
134- $FileStream.Close ()
135- }
136- catch {
137- $OpenFiles += $File.FullName
138- }
139- }
140- return $OpenFiles
141- }
144+
142145Write-Host - ForegroundColor Green " Generated SDK in '$ ( $Stopwatch.Elapsed.TotalMinutes ) ' minutes."
You can’t perform that action at this time.
0 commit comments