Skip to content

Commit c63a2a8

Browse files
committed
Add parameter RequireFailMessage for function Get-GitHubActionsInput
1 parent 407ba42 commit c63a2a8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psm1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ function Get-GitHubActionsInput {
579579
param(
580580
[Parameter(Mandatory = $true, ParameterSetName = 'one', Position = 0, ValueFromPipeline = $true)][ValidatePattern('^(?:[\da-z][\da-z_-]*)?[\da-z]$', ErrorMessage = '`{0}` is not match the require GitHub Actions input name pattern!')][Alias('Key')][string]$Name,
581581
[Parameter(ParameterSetName = 'one')][Alias('Force', 'Forced', 'Required')][switch]$Require,
582+
[Parameter(ParameterSetName = 'one')][Alias('ErrorMessage', 'FailMessage', 'RequireErrorMessage')][string]$RequireFailMessage = 'Input `{0}` is not defined!',
582583
[Parameter(Mandatory = $true, ParameterSetName = 'prefix')][ValidatePattern('^[\da-z][\da-z_-]*$', ErrorMessage = '`{0}` is not match the require GitHub Actions input name prefix pattern!')][Alias('KeyPrefix', 'KeyStartWith', 'NameStartWith', 'Prefix', 'PrefixKey', 'PrefixName', 'StartWith', 'StartWithKey', 'StartWithName')][string]$NamePrefix,
583584
[Parameter(Mandatory = $true, ParameterSetName = 'suffix')][ValidatePattern('^[\da-z_-]*[\da-z]$', ErrorMessage = '`{0}` is not match the require GitHub Actions input name suffix pattern!')][Alias('EndWith', 'EndWithKey', 'EndWithName', 'KeyEndWith', 'KeySuffix', 'NameEndWith', 'Suffix', 'SuffixKey', 'SuffixName')][string]$NameSuffix,
584585
[Parameter(ParameterSetName = 'all')][switch]$All,
@@ -604,7 +605,7 @@ function Get-GitHubActionsInput {
604605
$InputValue = Get-ChildItem -LiteralPath "Env:\INPUT_$($Name.ToUpper())" -ErrorAction 'SilentlyContinue'
605606
if ($null -eq $InputValue) {
606607
if ($Require) {
607-
return Write-GitHubActionsFail -Message "Input ``$Name`` is not defined!"
608+
return Write-GitHubActionsFail -Message ($RequireFailMessage -f $Name)
608609
}
609610
return $null
610611
}

0 commit comments

Comments
 (0)