@@ -1092,42 +1092,34 @@ Describe 'Common Tests - Spellcheck Files' -Tag 'Spellcheck' {
1092
1092
$spellcheckSettingsFilePath = $null
1093
1093
}
1094
1094
1095
+ $cSpellArgumentList = @ (
1096
+ ' "**/*.md"' ,
1097
+ ' --no-color'
1098
+ )
1095
1099
1100
+ if ($spellcheckSettingsFilePath )
1096
1101
{
1097
- <#
1098
- cSpell returns a verbose string in the error stream
1099
- "CSpell: Files checked: X, Issues found: Y in Z files".
1100
- It will return this in the error stream regardless if there
1101
- are any errors or not.
1102
- See issue https://github.com/Jason3S/cspell/issues/61.
1103
- This will redirect the output stream to file to be output
1104
- after the test fail.
1105
- #>
1106
- try
1107
- {
1108
- if ($spellcheckSettingsFilePath )
1109
- {
1110
- & cspell ' **/*.md' -- no- color -- config $spellcheckSettingsFilePath > SpellingErrors.txt
1111
- }
1112
- else
1113
- {
1114
- & cspell ' **/*.md' -- no- color > SpellingErrors.txt
1115
- }
1116
- }
1117
- catch
1118
- {
1119
- $noErrorsRegEx = ' CSpell: Files checked: [0-9]+, Issues found: [0] in [0-9]+ files'
1120
- Write-Verbose $_.Exception.Message - Verbose
1121
- <#
1122
- Only throw an error if there are 0 issues found in the
1123
- error message.
1124
- #>
1125
- if (-not $_.Exception.Message -match $noErrorsRegEx )
1126
- {
1127
- throw $_.Exception.Message
1128
- }
1129
- }
1130
- } | Should -Not - Throw
1102
+ $cSpellArgumentList += @ (
1103
+ ' --config' ,
1104
+ $spellcheckSettingsFilePath
1105
+ )
1106
+ }
1107
+
1108
+ # This must be last, we send output to the error file.
1109
+ $cSpellArgumentList += @ (
1110
+ (' >{0}' -f $errorFileName )
1111
+ )
1112
+
1113
+ $startProcessParameters = @ {
1114
+ FilePath = ' cspell'
1115
+ ArgumentList = $cSpellArgumentList
1116
+ Wait = $true
1117
+ PassThru = $true
1118
+ NoNewWindow = $true
1119
+ }
1120
+
1121
+ $process = Start-Process @startProcessParameters
1122
+ $process.ExitCode | Should - Be 0
1131
1123
} - ErrorVariable itBlockError
1132
1124
1133
1125
# If the It-block did not pass the test, output the spelling errors.
0 commit comments