mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Remove use of Test-Path in ConciseView (#12778)
This commit is contained in:
+4
-4
@@ -766,14 +766,14 @@ namespace System.Management.Automation.Runspaces
|
||||
$maxDepth = 10
|
||||
$ellipsis = ""`u{2026}""
|
||||
$resetColor = ''
|
||||
if ($Host.UI.SupportsVirtualTerminal -and !(Test-Path env:__SuppressAnsiEscapeSequences)) {
|
||||
if ($Host.UI.SupportsVirtualTerminal -and ([string]::IsNullOrEmpty($env:__SuppressAnsiEscapeSequences))) {
|
||||
$resetColor = [System.Management.Automation.VTUtility]::GetEscapeSequence(
|
||||
[System.Management.Automation.VTUtility+VT]::Reset
|
||||
)
|
||||
}
|
||||
|
||||
function Get-VT100Color([ConsoleColor] $color) {
|
||||
if (!$Host.UI.SupportsVirtualTerminal -or (Test-Path env:__SuppressAnsiEscapeSequences)) {
|
||||
if (!$Host.UI.SupportsVirtualTerminal -or !([string]::IsNullOrEmpty($env:__SuppressAnsiEscapeSequences))) {
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -1013,14 +1013,14 @@ namespace System.Management.Automation.Runspaces
|
||||
function Get-ConciseViewPositionMessage {
|
||||
|
||||
$resetColor = ''
|
||||
if ($Host.UI.SupportsVirtualTerminal -and !(Test-Path env:__SuppressAnsiEscapeSequences)) {
|
||||
if ($Host.UI.SupportsVirtualTerminal -and ([string]::IsNullOrEmpty($env:__SuppressAnsiEscapeSequences))) {
|
||||
$resetColor = [System.Management.Automation.VTUtility]::GetEscapeSequence(
|
||||
[System.Management.Automation.VTUtility+VT]::Reset
|
||||
)
|
||||
}
|
||||
|
||||
function Get-VT100Color([ConsoleColor] $color) {
|
||||
if (!$Host.UI.SupportsVirtualTerminal -or (Test-Path env:__SuppressAnsiEscapeSequences)) {
|
||||
if (!$Host.UI.SupportsVirtualTerminal -or !([string]::IsNullOrEmpty($env:__SuppressAnsiEscapeSequences))) {
|
||||
return ''
|
||||
}
|
||||
|
||||
|
||||
@@ -102,9 +102,15 @@ Describe 'Tests for $ErrorView' -Tag CI {
|
||||
|
||||
It "Position message does not contain line information" {
|
||||
|
||||
$e = & "$PSHOME/pwsh" -noprofile -command "foreach abc" | Out-String
|
||||
$e = & "$PSHOME/pwsh" -noprofile -command "foreach abc" 2>&1 | Out-String
|
||||
$e | Should -Not -BeNullOrEmpty
|
||||
$e | Should -Not -BeLike "*At line*"
|
||||
}
|
||||
|
||||
It "Error shows if `$PSModuleAutoLoadingPreference is set to 'none'" {
|
||||
$e = & "$PSHOME/pwsh" -noprofile -command '$PSModuleAutoLoadingPreference = ""none""; cmdletThatDoesntExist' 2>&1 | Out-String
|
||||
$e | Should -BeLike "*cmdletThatDoesntExist*"
|
||||
}
|
||||
}
|
||||
|
||||
Context 'NormalView tests' {
|
||||
|
||||
Reference in New Issue
Block a user