Skip to content

Commit

Permalink
Accept the owner advice in Utils.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleboyHarry authored Oct 2, 2020
1 parent e439c99 commit 3d212c7
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/Utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,13 @@ function Invoke-Utf8ConsoleCommand([ScriptBlock]$cmd) {
# A native executable that writes to stderr AND has its stderr redirected will generate non-terminating
# error records if the user has set $ErrorActionPreference to Stop. Override that value in this scope.
$ErrorActionPreference = 'Continue'
try {
[Console]::OutputEncoding = [Text.Encoding]::UTF8
& $cmd
try {
[Console]::OutputEncoding = $currentEncoding
}
catch [System.IO.IOException] {}
}
catch [System.IO.IOException] {
& $cmd
}

try { [Console]::OutputEncoding = [Text.Encoding]::UTF8 } catch [System.IO.IOException] {}
& $cmd
}
finally {
try { [Console]::OutputEncoding = $currentEncoding } catch [System.IO.IOException] {}

# Clear out stderr output that was added to the $Error collection, putting those errors in a module variable
if ($global:Error.Count -gt $errorCount) {
$numNewErrors = $global:Error.Count - $errorCount
Expand Down

0 comments on commit 3d212c7

Please sign in to comment.