Skip to content

Commit fbb0c54

Browse files
committed
Function Write-Fail add parameters Finally and ExitCode
1 parent 00d5c36 commit fbb0c54

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

hugoalh.GitHubActionsToolkit/module/log.psm1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ Line end of the issue file of the annotation.
201201
Column end of the issue file of the annotation.
202202
.PARAMETER Title
203203
Title of the error message.
204+
.PARAMETER Finally
205+
A script that execute before end the process, use to free any resources that are no longer needed.
206+
.PARAMETER ExitCode
207+
Exit code of the process.
204208
.OUTPUTS
205209
[Void]
206210
#>
@@ -214,10 +218,14 @@ Function Write-Fail {
214218
[Alias('Col', 'ColStart', 'ColumnStart', 'StartCol', 'StartColumn')][UInt32]$Column,
215219
[Alias('LineEnd')][UInt32]$EndLine,
216220
[Alias('ColEnd', 'ColumnEnd', 'EndCol')][UInt32]$EndColumn,
217-
[ValidatePattern('^.*$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header')][String]$Title
221+
[ValidatePattern('^.*$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header')][String]$Title,
222+
[ScriptBlock]$Finally = {},
223+
[ValidateRange(1, [Int32]::MaxValue)][Int32]$ExitCode = 1
218224
)
219225
Write-Annotation -Type 'Error' -Message $Message -File $File -Line $Line -Column $Column -EndLine $EndLine -EndColumn $EndColumn -Title $Title
220-
Exit 1
226+
Invoke-Command -ScriptBlock $Finally
227+
Exit $ExitCode
228+
Exit 1# For safety.
221229
}
222230
<#
223231
.SYNOPSIS

nodejs-wrapper-source/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@actions/tool-cache": "^2.0.1"
3535
},
3636
"devDependencies": {
37-
"@types/node": "^18.15.12",
37+
"@types/node": "^18.16.1",
3838
"@vercel/ncc": "^0.36.1",
3939
"typescript": "^5.0.4"
4040
},

nodejs-wrapper-source/pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)