File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -216,9 +216,12 @@ function Install-ModuleFast {
216216 HttpClient = $httpClient
217217 Update = $Update -or $PSCmdlet.ParameterSetName -eq ' ModuleFastInfo'
218218 }
219- Install-ModuleFastHelper @installHelperParams
219+ $installedModules = Install-ModuleFastHelper @installHelperParams
220220 Write-Progress - Id 1 - Activity ' Install-ModuleFast' - Completed
221221 Write-Verbose " `u{2705} All required modules installed! Exiting."
222+ if ($PassThru ) {
223+ Write-Output $installedModules
224+ }
222225 }
223226
224227 if ($CI ) {
@@ -761,14 +764,21 @@ function Install-ModuleFastHelper {
761764 }
762765
763766 $installed = 0
764- while ($installJobs.count -gt 0 ) {
767+ $installedModules = while ($installJobs.count -gt 0 ) {
765768 $ErrorActionPreference = ' Stop'
766769 $completedJob = $installJobs | Wait-Job - Any
767770 $completedJobContext = $completedJob | Receive-Job - Wait - AutoRemoveJob
768771 if (-not $installJobs.Remove ($completedJob )) { throw ' Could not remove completed job from list. This is a bug, report it' }
769772 $installed ++
770773 Write-Verbose " $ ( $completedJobContext.Module ) `: Installed to $ ( $completedJobContext.InstallPath ) "
771774 Write-Progress - Id 1 - Activity ' Install-ModuleFast' - Status " Install: $installed /$ ( $ModuleToInstall.count ) Modules" - PercentComplete ((($installed / $ModuleToInstall.count ) * 50 ) + 50 )
775+ $context.Module.Location = $completedJobContext.InstallPath
776+ # Output the module for potential future passthru
777+ $context.Module
778+ }
779+
780+ if ($PassThru ) {
781+ return $installedModules
772782 }
773783 }
774784}
Original file line number Diff line number Diff line change @@ -621,6 +621,11 @@ Describe 'Install-ModuleFast' -Tag 'E2E' {
621621 Test-Path $incompleteItemPath | Should - BeFalse
622622 }
623623
624+ It ' PassThru only reports on installed modules' {
625+ Install-ModuleFast @imfParams - Specification ' Pester=5.4.0' , ' Pester=5.4.1' - PassThru | Should - HaveCount 2
626+ Install-ModuleFast @imfParams - Specification ' Pester=5.4.0' , ' Pester=5.4.1' - PassThru | Should - HaveCount 0
627+ }
628+
624629 Describe ' GitHub Packages' {
625630 It ' Gets Specific Module' {
626631 $credential = [PSCredential ]::new(' Pester' , (Get-Secret - Name ' ReadOnlyPackagesGithubPAT' ))
You can’t perform that action at this time.
0 commit comments