-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix parsing the -Settings object as a path when the path object originates from an expression #915
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…sion that is not fully evaluated yet.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,6 +397,18 @@ Describe "Test CustomizedRulePath" { | |
} | ||
} | ||
|
||
It "Should process relative settings path even when settings path object is an expression" { | ||
try { | ||
$initialLocation = Get-Location | ||
Set-Location $PSScriptRoot | ||
$warnings = Invoke-ScriptAnalyzer -ScriptDefinition 'gci' -Settings (Join-Path (Get-Location).Path '.\SettingsTest\..\SettingsTest\Project1\PSScriptAnalyzerSettings.psd1') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this - in this case, the execution of Join-Path happens before the cmdlet is ever called, so this is just result of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if it is really There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the place to look is in the setter of the parameter value. You could set a breakpoint in the setter (around line 215 of InvokeScriptAnalyzerCommand.cs) and inspect the value (or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right that PowerShell evaluates it in the setter but the object is of type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it winds up being not a string, that's good enough. |
||
$warnings.Count | Should -Be 1 | ||
} | ||
finally { | ||
Set-Location $initialLocation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
} | ||
|
||
It "Should use the CustomRulePath parameter" { | ||
$settings = @{ | ||
CustomRulePath = "$directory\CommunityAnalyzerRules" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be
Push-Location
, that way you don't need to save the location at all.