Skip to content

Commit f2b8001

Browse files
committed
Fix parallel download helper visibility
1 parent 601b20a commit f2b8001

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

AwakeCoding.OpenSpecs/Public/Save-OpenSpecDocument.ps1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,18 @@ function Save-OpenSpecDocument {
163163
}
164164

165165
$moduleBase = (Get-Module -Name 'AwakeCoding.OpenSpecs' | Select-Object -First 1).ModuleBase
166+
$openSpecRequestPath = if ($moduleBase) { Join-Path -Path $moduleBase -ChildPath 'Private\Invoke-OpenSpecRequest.ps1' } else { $null }
166167
$useParallel = $Parallel -and $PSVersionTable.PSVersion.Major -ge 7 -and $toDownload.Count -gt 1
167168
$results = if ($useParallel) {
168169
$toDownload | ForEach-Object -Parallel {
169170
$link = $_.Link
170171
$destination = $_.Destination
171172
try {
172-
$currentModule = Get-Module -Name 'AwakeCoding.OpenSpecs' | Select-Object -First 1
173-
if (-not $currentModule -and $using:moduleBase) {
174-
Import-Module (Join-Path -Path $using:moduleBase -ChildPath 'AwakeCoding.OpenSpecs.psd1') -Force | Out-Null
173+
if (-not (Get-Command -Name 'Invoke-OpenSpecRequest' -CommandType Function -ErrorAction SilentlyContinue)) {
174+
if (-not $using:openSpecRequestPath -or -not (Test-Path -LiteralPath $using:openSpecRequestPath -PathType Leaf)) {
175+
throw 'Invoke-OpenSpecRequest helper script not found for parallel download.'
176+
}
177+
. $using:openSpecRequestPath
175178
}
176179
Invoke-OpenSpecRequest -Uri $link.Url -OutFile $destination | Out-Null
177180
[pscustomobject]@{

0 commit comments

Comments
 (0)