From d83be5b55583d7cef54161be7d16b5a00fa855fb Mon Sep 17 00:00:00 2001 From: "Shaun Lawrie (via GitHub Actions)" Date: Sat, 16 Mar 2024 02:00:17 +1300 Subject: [PATCH] Try stop errors breaking example rendering --- PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 | 7 ------- PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1 | 8 +++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 b/PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 index 7539b2f4..98eb1781 100644 --- a/PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 +++ b/PwshSpectreConsole.Docs/src/powershell/Mocks.psm1 @@ -36,11 +36,4 @@ function Stop-SpectreRecordingMock { $result += 'Hello world' + "`n" $result += '' return $result -} - -function Write-ErrorMock { - 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 3698f823..5f87a026 100644 --- a/PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1 +++ b/PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1 @@ -154,7 +154,13 @@ foreach ($doc in $docs) { } Write-Host "Modified sample:" Write-Host -ForegroundColor DarkGray $code - Invoke-Expression $code + if($code -like "*Write-Error*") { + $ErrorActionPreference = "SilentlyContinue" + Invoke-Expression $code + $ErrorActionPreference = "Stop" + } else { + Invoke-Expression $code + } $recording = Stop-SpectreRecording -Title "Example $([int]$example++)" $castName = ($doc.Name -replace '.md$', '' -replace '-', '').ToLower() + "Example$example"