diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index 3d703e6a5..5252ed337 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -36,6 +36,3 @@ jobs: TEST_USER_ORG_FG_PAT: ${{ secrets.TEST_USER_ORG_FG_PAT }} TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} - with: - Debug: true - Verbose: true diff --git a/src/functions/private/Commands/ConvertFrom-GitHubOutput.ps1 b/src/functions/private/Commands/ConvertFrom-GitHubOutput.ps1 index 03eec2271..3e74ee36c 100644 --- a/src/functions/private/Commands/ConvertFrom-GitHubOutput.ps1 +++ b/src/functions/private/Commands/ConvertFrom-GitHubOutput.ps1 @@ -42,6 +42,7 @@ Mandatory, ValueFromPipeline )] + [AllowNull()] [string[]] $InputData, # Whether to convert the input data to a hashtable @@ -55,38 +56,41 @@ } process { - foreach ($item in $InputData) { - if ($item -is [string]) { - $lines += $item -split "`n" - } + Write-Debug "[$stackPath] - Process - Start" + if (-not $InputData) { + $InputData = '' } - } - - end { + foreach ($line in $InputData) { + Write-Debug "Line: $line" + $lines += $line -split "`n" + } + Write-Debug "[$stackPath] - End - Start" # Initialize variables $result = @{} $i = 0 + Write-Debug "Lines: $($lines.Count)" + $lines | ForEach-Object { Write-Debug "[$_]" } + while ($i -lt $lines.Count) { $line = $lines[$i].Trim() Write-Debug "[$line]" - # Skip empty or delimiter lines - if ($line -match '^-+$' -or [string]::IsNullOrWhiteSpace($line)) { - Write-Debug "[$line] - Skipping empty line" - $i++ - continue - } - # Check for key=value pattern if ($line -match '^([^=]+)=(.*)$') { - Write-Debug "[$line] - key=value pattern" + Write-Debug ' - key=value pattern' $key = $Matches[1].Trim() $value = $Matches[2] + if ([string]::IsNullOrWhiteSpace($value) -or [string]::IsNullOrEmpty($value)) { + $result[$key] = '' + $i++ + continue + } + # Attempt to parse JSON if (Test-Json $value -ErrorAction SilentlyContinue) { - Write-Debug "[$line] - value is JSON" + Write-Debug "[$key] - value is JSON" $value = ConvertFrom-Json $value -AsHashtable:$AsHashtable } @@ -97,43 +101,57 @@ # Check for key<