@@ -131,8 +131,10 @@ GitHub Actions - Write Debug
131
131
Print a debug message to the log.
132
132
. PARAMETER Message
133
133
Message that need to log at debug level.
134
+ . PARAMETER SkipEmpty
135
+ Whether to skip empty message.
134
136
. PARAMETER SkipEmptyLine
135
- Whether to skip empty line.
137
+ Whether to skip empty message line.
136
138
. PARAMETER PassThru
137
139
Return the message. By default, this function does not generate any output.
138
140
. OUTPUTS
@@ -144,18 +146,43 @@ Function Write-Debug {
144
146
[OutputType (([String ], [Void ]))]
145
147
Param (
146
148
[Parameter (Mandatory = $True , Position = 0 , ValueFromPipeline = $True , ValueFromPipelineByPropertyName = $True )][AllowEmptyString ()][AllowNull ()][Alias (' Content' )][String ]$Message ,
149
+ [Alias (' NoEmpty' )][Switch ]$SkipEmpty ,
147
150
[Alias (' NoEmptyLine' )][Switch ]$SkipEmptyLine ,
148
151
[Switch ]$PassThru
149
152
)
153
+ Begin {
154
+ [Boolean ]$ShouldStdOut = $False
155
+ [String []]$MessageCache = @ ()
156
+ }
150
157
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
156
160
}
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
+ }
159
186
}
160
187
}
161
188
}
0 commit comments