Skip to content

Commit e103abf

Browse files
committed
Detect Github Workflow and Azure Pipelines and use DetailedView
1 parent 47c2a48 commit e103abf

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

build.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
ModuleManifest = "./source/ErrorView.psd1"
33
CopyPaths = 'ErrorView.format.ps1xml'
44
Prefix = 'prefix.ps1'
5+
Postfix = 'postfix.ps1'
56
# The rest of the paths are relative to the manifest
67
OutputDirectory = ".."
78
VersionedOutputDirectory = $true

source/postfix.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if ($script:ErrorView) {
2+
Set-ErrorView $ErrorView
3+
} elseif ($Env:GITHUB_ACTIONS -or $Env:TF_BUILD) {
4+
Set-ErrorView "DetailedErrorView"
5+
} else {
6+
Set-ErrorView "ConciseView"
7+
}

source/prefix.ps1

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,17 @@
1-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Justification = 'ErrorView is all about the ErrorView global variable')]
2-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Seriously. Stop complaining about ErrorView')]
31
param(
4-
$global:ErrorView = "Simple"
2+
$ErrorView
53
)
64

7-
# We need to _overwrite_ the ErrorView
8-
# So -PrependPath, instead of using FormatsToProcess
5+
# We need to _overwrite_ the ErrorView, so we must use -PrependPath
96
Update-FormatData -PrependPath $PSScriptRoot\ErrorView.format.ps1xml
107

118
Set-StrictMode -Off
129
$ErrorActionPreference = 'Stop'
1310
trap { 'Error found in error view definition: ' + $_.Exception.Message }
1411

15-
# Borrowed this one from https://github.com/chalk/ansi-regex
16-
$script:AnsiEscapes = [Regex]::new("([\u001b\u009b][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?(?:\u001b\u005c|\u0007))|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~])))", "Compiled");
17-
18-
# starting with an escape character and then...
19-
# ESC ] <anything> <ST> - where ST is either 1B 5C or 7 (BEL, aka `a)
20-
# ESC [ non-letters letter (or ~, =, @, >)
21-
# ESC ( <any character>
22-
# ESC O P
23-
# ESC O Q
24-
# ESC O R
25-
# ESC O S
26-
# $script:AnsiEscapes = [Regex]::new("\x1b[\(\)%`"&\.\/*+.-][@-Z]|\x1b\].*?(?:\u001b\u005c|\u0007|^)|\x1b\[\P{L}*[@-_A-Za-z^`\{\|\}~]|\x1b#\d|\x1b[!-~]", [System.Text.RegularExpressions.RegexOptions]::Compiled);
27-
2812
$script:ellipsis = [char]0x2026
2913
$script:newline = [Environment]::Newline
3014
$script:LineColors = @(
3115
"`e[38;2;255;255;255m"
3216
"`e[38;2;179;179;179m"
33-
)
17+
)

source/public/Set-ErrorView.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ filter Set-ErrorView {
2121
})]
2222
$View = "Normal"
2323
)
24-
# Update the enum every time, because how often do you change the error view?
24+
25+
# Re-create an update the enum every time, because how often do you change the error view?
2526
$Names = [System.Management.Automation.ErrorView].GetEnumNames() + @(
2627
Get-Command ConvertTo-*ErrorView -ListImported -ParameterName InputObject -ParameterType [System.Management.Automation.ErrorRecord]
2728
).Name -replace "ConvertTo-(\w+)ErrorView", '$1View' | Select-Object -Unique

0 commit comments

Comments
 (0)