debug PSScriptAnalyzer
This commit is contained in:
parent
5509e574c9
commit
1471e78af3
@ -33,35 +33,35 @@ function Invoke-InstallDependencies {
|
|||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
try {
|
try {
|
||||||
$ParamsPSScript = @{
|
$ParamsPSScript = @{
|
||||||
Name = 'PSScriptAnalyzer'
|
Name = 'PSScriptAnalyzer'
|
||||||
Scope = 'CurrentUser'
|
Scope = 'CurrentUser'
|
||||||
RequiredVersion = '1.20.0'
|
RequiredVersion = '1.20.0'
|
||||||
Force = $true
|
Force = $true
|
||||||
SkipPublisherCheck = $true
|
SkipPublisherCheck = $true
|
||||||
AllowClobber = $true
|
AllowClobber = $true
|
||||||
Verbose = $VerbosePreference
|
Verbose = $VerbosePreference
|
||||||
}
|
}
|
||||||
Install-Module @ParamsPSScript
|
Install-Module @ParamsPSScript
|
||||||
|
|
||||||
$ParamsPester = @{
|
$ParamsPester = @{
|
||||||
Name = 'Pester'
|
Name = 'Pester'
|
||||||
Scope = 'CurrentUser'
|
Scope = 'CurrentUser'
|
||||||
RequiredVersion = '5.3.3'
|
RequiredVersion = '5.3.3'
|
||||||
Force = $true
|
Force = $true
|
||||||
SkipPublisherCheck = $true
|
SkipPublisherCheck = $true
|
||||||
AllowClobber = $true
|
AllowClobber = $true
|
||||||
Verbose = $VerbosePreference
|
Verbose = $VerbosePreference
|
||||||
}
|
}
|
||||||
Install-Module @ParamsPester
|
Install-Module @ParamsPester
|
||||||
|
|
||||||
$ParamsPosh = @{
|
$ParamsPosh = @{
|
||||||
Name = 'posh-git'
|
Name = 'posh-git'
|
||||||
Scope = 'CurrentUser'
|
Scope = 'CurrentUser'
|
||||||
RequiredVersion = '1.1.0'
|
RequiredVersion = '1.1.0'
|
||||||
Force = $true
|
Force = $true
|
||||||
SkipPublisherCheck = $true
|
SkipPublisherCheck = $true
|
||||||
AllowClobber = $true
|
AllowClobber = $true
|
||||||
Verbose = $VerbosePreference
|
Verbose = $VerbosePreference
|
||||||
#ErrorAction = 'Stop'
|
#ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Install-Module @ParamsPosh
|
Install-Module @ParamsPosh
|
||||||
@ -96,8 +96,27 @@ function Invoke-Linter {
|
|||||||
Recurse = $true
|
Recurse = $true
|
||||||
Settings = './tools/PSScriptAnalyzerSettings.psd1'
|
Settings = './tools/PSScriptAnalyzerSettings.psd1'
|
||||||
ReportSummary = $true
|
ReportSummary = $true
|
||||||
|
ErrorAction = 'Stop'
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$AnalyzerResults = Invoke-ScriptAnalyzer @AnalyzerSettings
|
||||||
|
if ( $AnalyzerResults ) {
|
||||||
|
$AnalyzerResults | Sort-Object -Property @(
|
||||||
|
"ScriptName",
|
||||||
|
"Line"
|
||||||
|
) | Format-Table @(
|
||||||
|
"Severity",
|
||||||
|
"ScriptName",
|
||||||
|
"Line",
|
||||||
|
"RuleName",
|
||||||
|
"Message"
|
||||||
|
) -AutoSize | Out-String | Write-Verbose -Verbose
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error -Message 'PSScriptAnalyzer failer'
|
||||||
|
Write-Error -Message $_.Exception.Message -ErrorAction 'Stop'
|
||||||
}
|
}
|
||||||
Invoke-ScriptAnalyzer @AnalyzerSettings
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user