diff --git a/resources/Dependency.json b/resources/Dependency.json index 232341f..d6558a1 100644 --- a/resources/Dependency.json +++ b/resources/Dependency.json @@ -22,7 +22,7 @@ ] }, { - "Name": "PSGet", + "Name": "Existing", "Modules": [ "PowerShellGet" ] diff --git a/src/Helper/Resolve-Dependency.ps1 b/src/Helper/Resolve-Dependency.ps1 index 3893502..23f026c 100644 --- a/src/Helper/Resolve-Dependency.ps1 +++ b/src/Helper/Resolve-Dependency.ps1 @@ -66,19 +66,16 @@ function Resolve-Dependency { else { Write-Warning ("Could not find the dependency file: {0}" -f $DepFilePath) } - $res = @() } process { $SelectedDependency = $Dependency.Optional | Where-Object {$_.Name -match $Name} - + $res = @() foreach ($Module in $SelectedDependency.Modules) { $res += Test-Module -Name $Module } - if ($res.count -eq 0) { - return $false - } - elseif ($res -contains $false) { + # return false if there was not module at all + if (($res -contains $false) -or ($res.Count -eq 0)) { return $false } else { diff --git a/tests/Helper/01_Resolve-Dependency.Tests.ps1 b/tests/Helper/01_Resolve-Dependency.Tests.ps1 index 2c2e1f4..4d8f30e 100644 --- a/tests/Helper/01_Resolve-Dependency.Tests.ps1 +++ b/tests/Helper/01_Resolve-Dependency.Tests.ps1 @@ -44,7 +44,7 @@ Describe "Resolve-Dependency" { Context "Testing input variations" { Mock Get-ModuleBase {return "{0}\resources" -f $PWD} It "Should return true if all given dependencies exist" { - Resolve-Dependency -Name 'PSGet' | Should -Be $true + Resolve-Dependency -Name 'Existing' | Should -Be $true } It "Mixed results should return false" { Resolve-Dependency -Name 'PSGetMixed' | Should -Be $false