You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#The path to the lockfile. By default it is requires.lock.json in the current folder. This is ignored if CI is not present. It is generally not recommended to change this setting.
#Output a list of specifications for the modules to install. This is the same as -WhatIf but without the additional WhatIf Output
83
+
[Switch]$Plan,
82
84
#This will output the resulting modules that were installed.
83
85
[Switch]$PassThru
84
86
)
@@ -118,10 +120,6 @@ function Install-ModuleFast {
118
120
Add-DestinationToPSModulePath@addtoPathParams
119
121
}
120
122
121
-
$currentWhatIfPreference=$WhatIfPreference
122
-
#We do some stuff here that doesn't affect the system but triggers whatif, so we disable it
123
-
$WhatIfPreference=$false
124
-
125
123
#We want to maintain a single HttpClient for the life of the module. This isn't as big of a deal as it used to be but
126
124
#it is still a best practice.
127
125
if (-not$SCRIPT:__ModuleFastHttpClient-or$Source-ne$SCRIPT:__ModuleFastHttpClient.BaseAddress) {
@@ -133,26 +131,27 @@ function Install-ModuleFast {
133
131
$httpClient=$SCRIPT:__ModuleFastHttpClient
134
132
135
133
$cancelSource= [CancellationTokenSource]::new()
134
+
135
+
[List[ModuleFastSpec]]$ModulesToInstall=@()
136
+
[List[ModuleFastInfo]]$installPlan=@()
136
137
}
137
138
138
139
process {
139
140
#We initialize and type the container list here because there is a bug where the ParameterSet is not correct in the begin block if the pipeline is used. Null conditional keeps it from being reinitialized
$planAlreadySatisfiedMessage="`u{2705}$($ModulesToInstall.count) Module Specifications have all been satisfied by installed modules. If you would like to check for newer versions remotely, specify -Update"
Write-Verbose"`u{2705} All required modules installed! Exiting."
223
224
if ($CI) {
224
225
#FIXME: If a package was already installed, it doesn't show up in this lockfile.
225
226
Write-Verbose"Writing lockfile to $CILockFilePath"
226
227
[Dictionary[string,string]]$lockFile=@{}
227
-
$plan
228
+
$installPlan
228
229
|ForEach-Object {
229
230
$lockFile.Add($PSItem.Name,$PSItem.ModuleVersion)
230
231
}
@@ -332,12 +333,10 @@ function Get-ModuleFastPlan {
332
333
#We dont need this to be ConcurrentList because we only manipulate it in the "main" runspace.
333
334
[List[Task[String]]]$currentTasks=@()
334
335
336
+
#This is used to track the highest candidate if -Update was specified to force a remote lookup. If the candidate is still the most valid after remote lookup we can skip it without hitting disk to read the manifest again.
#This try finally is so that we can interrupt all http call tasks if Ctrl-C is pressed
337
339
foreach ($moduleSpecin$ModulesToResolve) {
338
-
#This is used to track the highest candidate if -Update was specified to force a remote lookup. If the candidate is still the most valid after remote lookup we can skip it without hitting disk to read the manifest again.
if ($Update-and ($ModuleSpec.Max-ne$candidateVersion)) {
1415
1414
Write-Debug"${ModuleSpec}: Skipping $candidateVersion because -Update was specified and the version does not exactly meet the upper bound of the spec or no upper bound was specified at all, meaning there is a possible newer version remotely."
1416
1415
#We can use this ref later to find out if our best remote version matches what is installed without having to read the manifest again
1417
-
if ($BestCandidate-and$manifestCandidate.ModuleVersion-gt$bestCandidate.Value.ModuleVersion) {
1416
+
if ($BestCandidate-and$manifestCandidate.ModuleVersion-gt$bestCandidate.Value[$moduleSpec]) {
1418
1417
Write-Debug"${ModuleSpec}: New Best Candidate Version $($manifestCandidate.ModuleVersion)"
0 commit comments