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
This pull request fixes an issue with the Install-ModuleFast function where it doesn't install modules in the specified destination if the same module is already installed in a different location on the system.
To address this issue, I have added a new parameter -DestinationOnly to the Install-ModuleFast function. When this parameter is specified, the function will only consider the specified destination and not any other paths currently in the PSModulePath. This is useful for scenarios where you want to ensure that the modules are installed in a specific location, such as in a CI environment.
I have also made changes to the Get-ModuleFastPlan and Find-LocalModule functions to support the new -DestinationOnly parameter.
Copy file name to clipboardExpand all lines: ModuleFast.psm1
+36-13Lines changed: 36 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -216,6 +216,8 @@ function Install-ModuleFast {
216
216
[Switch]$Prerelease,
217
217
#Using the CI switch will write a lockfile to the current folder. If this file is present and -CI is specified in the future, ModuleFast will only install the versions specified in the lockfile, which is useful for reproducing CI builds even if newer versions of software come out.
218
218
[Switch]$CI,
219
+
#Only consider the specified destination and not any other paths currently in the PSModulePath. This is useful for CI scenarios where you want to ensure that the modules are installed in a specific location.
220
+
[Switch]$DestinationOnly,
219
221
#How many concurrent installation threads to run. Each installation thread, given sufficient bandwidth, will likely saturate a full CPU core with decompression work. This defaults to the number of logical cores on the system. If your system uses HyperThreading and presents more logical cores than physical cores available, you may want to set this to half your number of logical cores for best performance.
#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.
Write-Debug"FOUND local module $($localMatch.Name)$($localMatch.ModuleVersion) at $($localMatch.Location.AbsolutePath) that satisfies $moduleSpec. Skipping..."
774
790
#TODO: Capture this somewhere that we can use it to report in the deploy plan
@@ -895,8 +911,7 @@ function Install-ModuleFastHelper {
895
911
$streamTask
896
912
}
897
913
898
-
#We are going to extract these straight out of memory, so we don't need to write the nupkg to disk
899
-
Write-Verbose"$($context.Module): Extracting to $($context.installPath)"
Write-Warning'No PSModulePaths found in $env:PSModulePath. If you are doing isolated testing you can disregard this.'
1557
1578
return
1558
1579
}
1559
1580
1560
1581
#We want to minimize reading the manifest files, so we will do a fast file-based search first and then do a more detailed inspection on high confidence candidate(s). Any module in any folder path that satisfies the spec will be sufficient, we don't care about finding the "latest" version, so we will return the first module that satisfies the spec. We will store potential candidates in this list, with their evaluated "guessed" version based on the folder name and the path. The first items added to the list should be the highest likelihood candidates in Path priority order, so no sorting should be necessary.
Write-Debug"${ModuleSpec}: Skipping PSModulePath $modulePath - Configured but does not exist."
@@ -1673,9 +1694,11 @@ function Find-LocalModule {
1673
1694
if ($Update-and ($ModuleSpec.Max-ne$candidateVersion)) {
1674
1695
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."
1675
1696
#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
1676
-
if ($bestCandidate.Value[$moduleSpec] -and$manifestCandidate.ModuleVersion-gt$bestCandidate.Value[$moduleSpec]) {
1677
-
Write-Debug"${ModuleSpec}: New Best Candidate Version $($manifestCandidate.ModuleVersion)"
0 commit comments