From 328a9c551e64cce0537a9ff15116009670894145 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 26 Jan 2024 19:09:54 -0800 Subject: [PATCH] -PassThru Output is broken Fixes #70 --- ModuleFast.psm1 | 4 ++-- ModuleFast.tests.ps1 | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ModuleFast.psm1 b/ModuleFast.psm1 index caf27f6..c29b3bc 100644 --- a/ModuleFast.psm1 +++ b/ModuleFast.psm1 @@ -1019,9 +1019,9 @@ function Install-ModuleFastHelper { $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 + $completedJobContext.Module.Location = $completedJobContext.InstallPath #Output the module for potential future passthru - $context.Module + $completedJobContext.Module } if ($PassThru) { diff --git a/ModuleFast.tests.ps1 b/ModuleFast.tests.ps1 index 67896d4..94b519a 100644 --- a/ModuleFast.tests.ps1 +++ b/ModuleFast.tests.ps1 @@ -736,7 +736,12 @@ Describe 'Install-ModuleFast' -Tag 'E2E' { $actual | Should -BeLike '*incomplete installation detected*' Test-Path $incompleteItemPath | Should -BeFalse } - + It 'PassThru has proper matching output' { + $actual = Install-ModuleFast @imfParams -Specification 'PrereleaseTest=0.0.1', 'ImportExcel=7.8.6', 'PendingReboot=0.9.0.6' -PassThru + ($actual | Where-Object Name -EQ 'ImportExcel').ModuleVersion | Should -Be '7.8.6' + ($actual | Where-Object Name -EQ 'PrereleaseTest').ModuleVersion | Should -Be '0.0.1' + ($actual | Where-Object Name -EQ 'PendingReboot').ModuleVersion | Should -Be '0.9.0.6' + } 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