diff --git a/eng/common/scripts/check-spelling-in-changed-files.ps1 b/eng/common/scripts/check-spelling-in-changed-files.ps1 index aee066a5c0c1..b0d43b210509 100644 --- a/eng/common/scripts/check-spelling-in-changed-files.ps1 +++ b/eng/common/scripts/check-spelling-in-changed-files.ps1 @@ -115,6 +115,7 @@ $spellingErrors = &"$PSScriptRoot/../spelling/Invoke-Cspell.ps1" ` -CspellConfigPath $CspellConfigPath ` -SpellCheckRoot $SpellCheckRoot ` -FileList $changedFilePaths +$cspellExitCode = $LASTEXITCODE if ($spellingErrors) { $errorLoggingFunction = Get-Item 'Function:LogWarning' @@ -130,6 +131,9 @@ if ($spellingErrors) { if ($ExitWithError) { exit 1 } +} elseif ($cspellExitCode -ne 0 -and $ExitWithError) { + LogError "CSpell exited with code $cspellExitCode. This may indicate a configuration error or other failure in the spell checking tool." + exit 1 } else { Write-Host "No spelling errors detected" }