Commit 62cb759
fix: pass -Scope correctly when Target=CurrentUser for PowerShellGet package (#167)
## What this changes
Fixes a variable reference bug in PSDepend/PSDependScripts/Package.ps1
where the elseif condition checked $Scope (undefined at that point)
instead of $Dependency.Target. As a result, -Scope was never passed to
Install-Package when Target = 'CurrentUser', causing an elevation
prompt. The Target→Scope logic has been restructured to match the
pattern used in PSGalleryModule.ps1.
## Why
When invoking PSDepend with -Target CurrentUser for PowerShellGet
packages, users were unexpectedly prompted for elevation because the
scope was never set.
Closes #130
## Type of change
- [X] Bug fix (non-breaking change that corrects incorrect behavior)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that changes existing behavior)
- [ ] Chore / refactor / documentation (no behavior change)
## Checklist
- [ ] Pester tests added or updated to cover the change
- [X] `Invoke-psake Analyze` passes locally with no new warnings
- [X] `Invoke-psake Test` passes locally on at least one platform
- [ ] `CHANGELOG.md` updated (required for any user-facing change)
- [ ] Documentation updated if behavior changed
## Additional notes
The fix mirrors the existing logic in PSGalleryModule.ps1 which handles
the same Target→Scope mapping correctly.
---------
Co-authored-by: Gilbert Sanchez <me@gilbertsanchez.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Marcel Dutt <41046352+sit-md@users.noreply.github.com>
Co-authored-by: Maarten Piederiet <mpiederiet@users.noreply.github.com>1 parent b077f24 commit 62cb759
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | 127 | | |
129 | | - | |
| 128 | + | |
130 | 129 | | |
131 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| |||
0 commit comments