@@ -131,8 +131,10 @@ GitHub Actions - Write Debug
131131Print a debug message to the log.
132132. PARAMETER Message
133133Message that need to log at debug level.
134+ . PARAMETER SkipEmpty
135+ Whether to skip empty message.
134136. PARAMETER SkipEmptyLine
135- Whether to skip empty line.
137+ Whether to skip empty message line.
136138. PARAMETER PassThru
137139Return the message. By default, this function does not generate any output.
138140. OUTPUTS
@@ -144,18 +146,43 @@ Function Write-Debug {
144146 [OutputType (([String ], [Void ]))]
145147 Param (
146148 [Parameter (Mandatory = $True , Position = 0 , ValueFromPipeline = $True , ValueFromPipelineByPropertyName = $True )][AllowEmptyString ()][AllowNull ()][Alias (' Content' )][String ]$Message ,
149+ [Alias (' NoEmpty' )][Switch ]$SkipEmpty ,
147150 [Alias (' NoEmptyLine' )][Switch ]$SkipEmptyLine ,
148151 [Switch ]$PassThru
149152 )
153+ Begin {
154+ [Boolean ]$ShouldStdOut = $False
155+ [String []]$MessageCache = @ ()
156+ }
150157 Process {
151- If (
152- ! $SkipEmptyLine.IsPresent -or
153- ($SkipEmptyLine.IsPresent -and $Message.Length -gt 0 )
154- ) {
155- Write-GitHubActionsStdOutCommand - StdOutCommand ' debug' - Value $Message
158+ If ($SkipEmpty.IsPresent -and ! $ShouldStdOut -and $Message.Length -eq 0 ) {
159+ $MessageCache += $Message
156160 }
157- If ($PassThru.IsPresent ) {
158- Write-Output - InputObject $Message
161+ Else {
162+ $ShouldStdOut = $True
163+ If ($MessageCache.Count -gt 0 ) {
164+ ForEach ($Line In $MessageCache ) {
165+ If (
166+ ! $SkipEmptyLine.IsPresent -or
167+ ($SkipEmptyLine.IsPresent -and $Line.Length -gt 0 )
168+ ) {
169+ Write-GitHubActionsStdOutCommand - StdOutCommand ' debug' - Value $Line
170+ }
171+ If ($PassThru.IsPresent ) {
172+ Write-Output - InputObject $Line
173+ }
174+ }
175+ $MessageCache = @ ()
176+ }
177+ If (
178+ ! $SkipEmptyLine.IsPresent -or
179+ ($SkipEmptyLine.IsPresent -and $Message.Length -gt 0 )
180+ ) {
181+ Write-GitHubActionsStdOutCommand - StdOutCommand ' debug' - Value $Message
182+ }
183+ If ($PassThru.IsPresent ) {
184+ Write-Output - InputObject $Message
185+ }
159186 }
160187 }
161188}
0 commit comments