Skip to content

Commit

Permalink
Mock write-error
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie committed Mar 15, 2024
1 parent 6682149 commit 4b1d7b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 7 additions & 0 deletions PwshSpectreConsole.Docs/src/powershell/Mocks.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ function Stop-SpectreRecordingMock {
$result += '<span>Hello</span><span> </span><span style="color: #FF0000">world</span>' + "`n"
$result += '</pre>'
return $result
}

function Write-Error {
param (
[string] $Message
)
Write-SpectreHost "[red]$Message[/]"
}
9 changes: 1 addition & 8 deletions PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4b1d7b7

Please sign in to comment.