diff --git a/PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 b/PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 index 98eb1781..ff33f5c7 100644 --- a/PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 +++ b/PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 @@ -36,4 +36,11 @@ function Stop-SpectreRecordingMock { $result += 'Hello world' + "`n" $result += '' return $result +} + +function Write-Error { + param ( + [string] $Message + ) + Write-SpectreHost "[red]$Message[/]" } \ No newline at end of file diff --git a/PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1 b/PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1 index 840aa8e1..3698f823 100644 --- a/PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1 +++ b/PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1 @@ -154,14 +154,7 @@ foreach ($doc in $docs) { } Write-Host "Modified sample:" Write-Host -ForegroundColor DarkGray $code - if($code -like "*Write-Error*") { - $ErrorActionPreference = "Continue" - $previousErrorActionPreference = $ErrorActionPreference - Invoke-Expression $code - $ErrorActionPreference = $previousErrorActionPreference - } else { - Invoke-Expression $code - } + Invoke-Expression $code $recording = Stop-SpectreRecording -Title "Example $([int]$example++)" $castName = ($doc.Name -replace '.md$', '' -replace '-', '').ToLower() + "Example$example"