Skip to content

🪲 [Fix]: Fix setting the $ErrorView setting via inputs #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 16, 2025
6 changes: 6 additions & 0 deletions .github/workflows/TestWorkflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ jobs:
Get-Content $env:GITHUB_OUTPUT -Raw | Set-GitHubStepSummary
}

LogGroup "ErrorView should be 'NormalView' - [$ErrorView]" {
if ($ErrorView -ne 'NormalView') {
throw 'ErrorView is not NormalView'
}
}

- name: Run-test
shell: pwsh
env:
Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ runs:
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
try {
${{ github.action_path }}/scripts/init.ps1
${{ github.action_path }}/scripts/info.ps1
Expand Down
17 changes: 0 additions & 17 deletions scripts/init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ param()
begin {
$scriptName = $MyInvocation.MyCommand.Name
Write-Debug "[$scriptName] - Start"
$PSStyle.OutputRendering = 'Ansi'

# Configure ErrorView based on input parameter
if (-not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView)) {
$validViews = @('NormalView', 'CategoryView', 'ConciseView', 'DetailedView')
$errorViewSetting = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView

# Simply find the first validView that matches the input using wildcards
$matchedView = $validViews | Where-Object { $_ -like "*$errorViewSetting*" } | Select-Object -First 1

if ($matchedView) {
Write-Debug "[$scriptName] - Input [$errorViewSetting] matched with [$matchedView]"
$ErrorView = $matchedView
} else {
Write-Warning "[$scriptName] - Invalid ErrorView value: [$errorViewSetting]. Using default."
}
}
}

process {
Expand Down
Loading