Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

## [Unreleased]

### Fixed

- `Get-Dependency -InputObject` no longer mutates the caller's hashtable:
`PSDependOptions` is now preserved after the call, so a second invocation
with the same object still honors global options such as `Target` (#35).

## [0.4.1] - 2026-06-12

### Added
Expand Down Expand Up @@ -127,7 +133,7 @@
### Fixed

- `Get-Dependency` operator-precedence bug when `DependencyType` is
set inside `PSDependOptions`: parenthesization was incorrect, so the

Check warning on line 136 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (parenthesization)
global default failed to apply to dependencies without an explicit
type (#131, #173).
- `Find-PSDependLocally` now consults *all* installed versions of a
Expand All @@ -138,7 +144,7 @@
passing it to `Import-Module`, preventing failures when prerelease
segments or `vX.Y.Z` tags appear in the resolved version (#140).
- `Chocolatey` install path now passes `--yes` to `choco install`
(previously the script contained the typo `--yess`), so installs

Check warning on line 147 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (yess) Suggestions: (yes, yeas, yens, yeps, yest)
no longer hang waiting on confirmation, and the surrounding code
was tidied for readability (#174).
- `Git` handler now uses the full `Dependency.Target` path when the
Expand Down
2 changes: 1 addition & 1 deletion PSDepend/Public/Get-Dependency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

These are parsed from dependency PSD1 files as follows:

Simple syntax, intepreted:

Check warning on line 28 in PSDepend/Public/Get-Dependency.ps1

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (intepreted) Suggestions: (interpreted, integrated, interested, interpreter, Integrated)
@{
DependencyName = 'Version'
}
Expand Down Expand Up @@ -128,7 +128,7 @@
.LINK
https://github.com/PowerShellOrg/PSDepend
#>
[cmdletbinding(DefaultParameterSetName = 'File')]

Check warning on line 131 in PSDepend/Public/Get-Dependency.ps1

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (cmdletbinding)
param(
[parameter(ParameterSetName = 'File')]
[string[]]$Path = $PWD.Path,
Expand All @@ -146,7 +146,7 @@
[hashtable]$Credentials
)

# Helper to pick from global psdependoptions, or return a default

Check warning on line 149 in PSDepend/Public/Get-Dependency.ps1

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (psdependoptions)
function Get-GlobalOption {
param(
$Options = $PSDependOptions,
Expand Down Expand Up @@ -179,7 +179,7 @@
}

function Inject-Variable {
[cmdletbinding()]

Check warning on line 182 in PSDepend/Public/Get-Dependency.ps1

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (cmdletbinding)
param( $Value )
$Output = $Value
switch ($Value) {
Expand Down Expand Up @@ -214,14 +214,14 @@

# Helper to take in a dependency hash and output Dependency objects
function Parse-Dependency {
[cmdletbinding()]

Check warning on line 217 in PSDepend/Public/Get-Dependency.ps1

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (cmdletbinding)
param(
$ParamSet = $PSCmdlet.ParameterSetName
)

# Global settings....
$PSDependOptions = $null
if ($Dependencies.Containskey('PSDependOptions')) {

Check warning on line 224 in PSDepend/Public/Get-Dependency.ps1

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (Containskey) Suggestions: (contains, contained, container)
$PSDependOptions = $Dependencies.PSDependOptions
$Dependencies.Remove('PSDependOptions')
}
Expand Down Expand Up @@ -358,7 +358,7 @@
$DependencyType = 'Git'
}
else {
# finally, psgallerymodule

Check warning on line 361 in PSDepend/Public/Get-Dependency.ps1

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (psgallerymodule)
$DependencyType = 'PSGalleryModule'
}
}
Expand Down Expand Up @@ -437,7 +437,7 @@
elseif ($PSCmdlet.ParameterSetName -eq 'Hashtable') {
$DependencyFile = 'Hashtable'
$ParsedDependencies = foreach ($InputDependency in $InputObject) {
$Dependencies = $InputDependency
$Dependencies = $InputDependency.Clone()

Parse-Dependency -ParamSet $PSCmdlet.ParameterSetName
}
Expand Down
21 changes: 21 additions & 0 deletions Tests/PSDepend.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeDiscovery {
if ($null -eq $env:BHPSModuleManifest) {

Check warning on line 2 in Tests/PSDepend.Tests.ps1

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run Linters

Unknown word (BHPS) Suggestions: (baps, bops, bhp, BHP, bps)
& "$PSScriptRoot/../Build.ps1" -Task Init
}
$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest
Expand Down Expand Up @@ -119,6 +119,27 @@
$Dependencies | Should -BeNullOrEmpty
}

It 'Does not mutate the caller''s InputObject — PSDependOptions key survives after Get-Dependency' {
$inputObj = @{
PSDependOptions = @{ Target = 'CurrentUser' }
Pester = 'latest'
}
$null = Get-Dependency -InputObject $inputObj
$inputObj.ContainsKey('PSDependOptions') | Should -Be $True
}

It 'Does not mutate the caller''s InputObject — PSDependOptions honored on a second Get-Dependency call' {
$inputObj = @{
PSDependOptions = @{ Target = 'CurrentUser' }
Pester = 'latest'
}
$null = Get-Dependency -InputObject $inputObj
$deps2 = Get-Dependency -InputObject $inputObj
$inputObj.ContainsKey('PSDependOptions') | Should -Be $True
$inputObj.PSDependOptions.Target | Should -Be 'CurrentUser'
($deps2 | Where-Object DependencyName -eq 'Pester').Target | Should -Be 'CurrentUser'
}
Comment thread
HeyItsGilbert marked this conversation as resolved.

It 'Parses -InputObject hashtable as PSGalleryModule by default' {
$Dependencies = Get-Dependency -InputObject @{ Pester = 'latest' }
$Dependencies.DependencyName | Should -Be 'Pester'
Expand Down
Loading