Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .build/CodeFormatter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ foreach ($file in $scriptFiles) {
}
}

$reloadFile = $false
$before = Get-Content $file -Raw
$after = Invoke-Formatter -ScriptDefinition (Get-Content $file -Raw) -Settings $repoRoot\PSScriptAnalyzerSettings.psd1
$after = Invoke-Formatter -ScriptDefinition $before -Settings $repoRoot\PSScriptAnalyzerSettings.psd1

if ($before -ne $after) {
Write-Warning ("{0}:" -f $file)
Expand All @@ -71,6 +72,7 @@ foreach ($file in $scriptFiles) {
try {
Set-Content -Path $file -Value $after -Encoding utf8NoBOM
Write-Information "Saved $file with formatting corrections."
$reloadFile = $true
} catch {
$filesFailed = $true
Write-Warning "Failed to save $file with formatting corrections."
Expand All @@ -81,6 +83,16 @@ foreach ($file in $scriptFiles) {
}
}

if ($reloadFile) {
$before = Get-Content -Path $file -Raw
}

if (-not ([string]::IsNullOrWhiteSpace($before[-1]))) {
Write-Warning $file
Write-Warning "Failed to have a whitespace at the end of the file"
$filesFailed = $true
}

$analyzerResults = Invoke-ScriptAnalyzer -Path $file -Settings $repoRoot\PSScriptAnalyzerSettings.psd1
if ($null -ne $analyzerResults) {
$filesFailed = $true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ Function Write-CheckSearchProcessState {
Write-ScriptOutput "----------------------------------------"
Write-ScriptOutput ""
}
}
}
2 changes: 1 addition & 1 deletion Search/Troubleshoot-ModernSearch/Write/Write-Error.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Function Write-Error {
Write-LogInformation "Error - $Message"
Microsoft.PowerShell.Utility\Write-Error $Message
}
}
}
2 changes: 1 addition & 1 deletion Search/Troubleshoot-ModernSearch/Write/Write-Warning.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Function Write-Warning {
Write-LogInformation "Warning - $Message"
Microsoft.PowerShell.Utility\Write-Warning $Message
}
}
}
2 changes: 1 addition & 1 deletion Shared/Get-ServerPendingReboot.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ Function Get-ServerRebootPending {
PendingRebootLocations = $pendingRebootLocations
}
}
}
}
2 changes: 1 addition & 1 deletion Shared/Tests/Get-NETFrameworkVersion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ Describe "Testing $scriptName" {
Assert-MockCalled -CommandName Write-Host -Exactly 1 -ParameterFilter { $Object -eq "Write-CustomScriptBlock" }
}
}
}
}
2 changes: 1 addition & 1 deletion Shared/Tests/Get-ServerPendingReboot.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ Describe "Testing Get-ServerRebootPending" {
$results.PendingReboot | Should -Be $true
}
}
}
}
2 changes: 1 addition & 1 deletion Shared/Tests/Invoke-ScriptBlockHandler.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ Describe "Testing $scriptName" {
Assert-MockCalled -CommandName Write-Host -Exactly 1 -ParameterFilter { $Object -eq "Test-PesterCatchAction" }
}
}
}
}