Skip to content

✨Add PassThru Implementation and Test #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ModuleFast.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ function Install-ModuleFast {
HttpClient = $httpClient
Update = $Update -or $PSCmdlet.ParameterSetName -eq 'ModuleFastInfo'
}
Install-ModuleFastHelper @installHelperParams
$installedModules = Install-ModuleFastHelper @installHelperParams
Write-Progress -Id 1 -Activity 'Install-ModuleFast' -Completed
Write-Verbose "`u{2705} All required modules installed! Exiting."
if ($PassThru) {
Write-Output $installedModules
}
}

if ($CI) {
Expand Down Expand Up @@ -761,14 +764,21 @@ function Install-ModuleFastHelper {
}

$installed = 0
while ($installJobs.count -gt 0) {
$installedModules = while ($installJobs.count -gt 0) {
$ErrorActionPreference = 'Stop'
$completedJob = $installJobs | Wait-Job -Any
$completedJobContext = $completedJob | Receive-Job -Wait -AutoRemoveJob
if (-not $installJobs.Remove($completedJob)) { throw 'Could not remove completed job from list. This is a bug, report it' }
$installed++
Write-Verbose "$($completedJobContext.Module)`: Installed to $($completedJobContext.InstallPath)"
Write-Progress -Id 1 -Activity 'Install-ModuleFast' -Status "Install: $installed/$($ModuleToInstall.count) Modules" -PercentComplete ((($installed / $ModuleToInstall.count) * 50) + 50)
$context.Module.Location = $completedJobContext.InstallPath
#Output the module for potential future passthru
$context.Module
}

if ($PassThru) {
return $installedModules
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions ModuleFast.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@ Describe 'Install-ModuleFast' -Tag 'E2E' {
Test-Path $incompleteItemPath | Should -BeFalse
}

It 'PassThru only reports on installed modules' {
Install-ModuleFast @imfParams -Specification 'Pester=5.4.0', 'Pester=5.4.1' -PassThru | Should -HaveCount 2
Install-ModuleFast @imfParams -Specification 'Pester=5.4.0', 'Pester=5.4.1' -PassThru | Should -HaveCount 0
}

Describe 'GitHub Packages' {
It 'Gets Specific Module' {
$credential = [PSCredential]::new('Pester', (Get-Secret -Name 'ReadOnlyPackagesGithubPAT'))
Expand Down