@@ -33,35 +33,35 @@ function Invoke-InstallDependencies {
3333 $ErrorActionPreference = ' Stop'
3434 try {
3535 $ParamsPSScript = @ {
36- Name = ' PSScriptAnalyzer'
37- Scope = ' CurrentUser'
38- RequiredVersion = ' 1.20.0'
39- Force = $true
36+ Name = ' PSScriptAnalyzer'
37+ Scope = ' CurrentUser'
38+ RequiredVersion = ' 1.20.0'
39+ Force = $true
4040 SkipPublisherCheck = $true
41- AllowClobber = $true
42- Verbose = $VerbosePreference
41+ AllowClobber = $true
42+ Verbose = $VerbosePreference
4343 }
4444 Install-Module @ParamsPSScript
4545
4646 $ParamsPester = @ {
47- Name = ' Pester'
48- Scope = ' CurrentUser'
49- RequiredVersion = ' 5.3.3'
50- Force = $true
47+ Name = ' Pester'
48+ Scope = ' CurrentUser'
49+ RequiredVersion = ' 5.3.3'
50+ Force = $true
5151 SkipPublisherCheck = $true
52- AllowClobber = $true
53- Verbose = $VerbosePreference
52+ AllowClobber = $true
53+ Verbose = $VerbosePreference
5454 }
5555 Install-Module @ParamsPester
5656
5757 $ParamsPosh = @ {
58- Name = ' posh-git'
59- Scope = ' CurrentUser'
60- RequiredVersion = ' 1.1.0'
61- Force = $true
58+ Name = ' posh-git'
59+ Scope = ' CurrentUser'
60+ RequiredVersion = ' 1.1.0'
61+ Force = $true
6262 SkipPublisherCheck = $true
63- AllowClobber = $true
64- Verbose = $VerbosePreference
63+ AllowClobber = $true
64+ Verbose = $VerbosePreference
6565 # ErrorAction = 'Stop'
6666 }
6767 Install-Module @ParamsPosh
@@ -96,8 +96,27 @@ function Invoke-Linter {
9696 Recurse = $true
9797 Settings = ' ./tools/PSScriptAnalyzerSettings.psd1'
9898 ReportSummary = $true
99+ ErrorAction = ' Stop'
100+ }
101+ try {
102+ $AnalyzerResults = Invoke-ScriptAnalyzer @AnalyzerSettings
103+ if ( $AnalyzerResults ) {
104+ $AnalyzerResults | Sort-Object - Property @ (
105+ " ScriptName" ,
106+ " Line"
107+ ) | Format-Table @ (
108+ " Severity" ,
109+ " ScriptName" ,
110+ " Line" ,
111+ " RuleName" ,
112+ " Message"
113+ ) - AutoSize | Out-String | Write-Verbose - Verbose
114+ }
115+ }
116+ catch {
117+ Write-Error - Message ' PSScriptAnalyzer failer'
118+ Write-Error - Message $_.Exception.Message - ErrorAction ' Stop'
99119 }
100- Invoke-ScriptAnalyzer @AnalyzerSettings
101120 }
102121}
103122
0 commit comments