Skip to content

Commit 3bca679

Browse files
author
James Brundage
committed
requires transpiler: Caching Find-Module results (Fixes #318)
1 parent fcb6e0d commit 3bca679

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Transpilers/Keywords/Requires.psx.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ process {
134134
if ($foundModuleRequirement -and $requireLatest) {
135135
# then find if there is a more recent version.
136136
Write-Verbose "Searching for a more recent version of $($foundModuleRequirement.Name)@$($foundModuleRequirement.Version)"
137-
$foundModuleInGallery = Find-Module -Name $foundModuleRequirement.Name
137+
138+
if (-not $script:FoundModuleVersions) {
139+
$script:FoundModuleVersions = @{}
140+
}
141+
142+
if (-not $script:FoundModuleVersions[$foundModuleRequirement.Name]) {
143+
$script:FoundModuleVersions[$foundModuleRequirement.Name] = Find-Module -Name $foundModuleRequirement.Name
144+
}
145+
$foundModuleInGallery = $script:FoundModuleVersions[$foundModuleRequirement.Name]
138146
if ($foundModuleInGallery -and
139147
([Version]$foundModuleInGallery.Version -gt [Version]$foundModuleRequirement.Version)) {
140148
Write-Verbose "$($foundModuleInGallery.Name)@$($foundModuleInGallery.Version)"

0 commit comments

Comments
 (0)