Skip to content

Commit f8316d7

Browse files
HeyItsGilbertclaude
andcommitted
fix(Get-Dependency): correct operator precedence in Parse-Dependency elseif conditions
When DependencyType was set globally via PSDependOptions, PowerShell's -and/-or precedence caused the simple-string elseif branches to match even for hashtable-syntax dependencies, assigning the whole hashtable to Version instead of parsing it correctly. Parenthesise the (-not $DependencyType -or $DependencyType -eq 'X') sub-expression in all three branches (PSGalleryModule, GitHub, Git). Fixes #131 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 73b06ec commit f8316d7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

PSDepend/Public/Get-Dependency.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ function Get-Dependency {
258258
# It doesn't look like a git repo, and simple syntax: PSGalleryModule
259259
elseif( $DependencyHash -is [string] -and
260260
$Dependency -notmatch '/' -and
261-
-not $DependencyType -or
262-
$DependencyType -eq 'PSGalleryModule') {
261+
(-not $DependencyType -or
262+
$DependencyType -eq 'PSGalleryModule')) {
263263
[PSCustomObject]@{
264264
PSTypeName = 'PSDepend.Dependency'
265265
DependencyFile = $DependencyFile
@@ -284,8 +284,8 @@ function Get-Dependency {
284284
elseif($DependencyHash -is [string] -and
285285
$Dependency -match '/' -and
286286
$Dependency.split('/').count -eq 2 -and
287-
-not $DependencyType -or
288-
$DependencyType -eq 'GitHub') {
287+
(-not $DependencyType -or
288+
$DependencyType -eq 'GitHub')) {
289289
[PSCustomObject]@{
290290
PSTypeName = 'PSDepend.Dependency'
291291
DependencyFile = $DependencyFile
@@ -308,8 +308,8 @@ function Get-Dependency {
308308
# It looks like a git repo, and simple syntax: Git
309309
elseif($DependencyHash -is [string] -and
310310
$Dependency -match '/' -and
311-
-not $DependencyType -or
312-
$DependencyType -eq 'Git' ) {
311+
(-not $DependencyType -or
312+
$DependencyType -eq 'Git')) {
313313
[PSCustomObject]@{
314314
PSTypeName = 'PSDepend.Dependency'
315315
DependencyFile = $DependencyFile

0 commit comments

Comments
 (0)