Skip to content

Commit 081ea68

Browse files
committed
20220805A
1 parent f04b93e commit 081ea68

File tree

9 files changed

+108
-78
lines changed

9 files changed

+108
-78
lines changed

hugoalh.GitHubActionsToolkit/module/artifact.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Function Test-ArtifactName {
147147
[CmdletBinding()]
148148
[OutputType([Boolean])]
149149
Param (
150-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyString()][Alias('Input', 'Object')][String]$InputObject
150+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][Alias('Input', 'Object')][String]$InputObject
151151
)
152152
Begin {}
153153
Process {
@@ -169,7 +169,7 @@ Function Test-ArtifactPath {
169169
[CmdletBinding()]
170170
[OutputType([Boolean])]
171171
Param (
172-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyString()][Alias('Input', 'Object')][String]$InputObject
172+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][Alias('Input', 'Object')][String]$InputObject
173173
)
174174
Begin {}
175175
Process {

hugoalh.GitHubActionsToolkit/module/cache.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Function Test-CacheKey {
152152
[CmdletBinding()]
153153
[OutputType([Boolean])]
154154
Param (
155-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyString()][Alias('Input', 'Object')][String]$InputObject
155+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][Alias('Input', 'Object')][String]$InputObject
156156
)
157157
Begin {}
158158
Process {

hugoalh.GitHubActionsToolkit/module/command-base.psm1

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,52 @@
11
#Requires -PSEdition Core
22
#Requires -Version 7.2
3-
Class GitHubActionsCommand {
4-
Static [String]EscapeContent([String]$InputObject) {
5-
Return [GitHubActionsCommand]::EscapeValue($InputObject)
6-
}
7-
Static [String]EscapeMessage([String]$InputObject) {
8-
Return [GitHubActionsCommand]::EscapeValue($InputObject)
9-
}
10-
Static [String]EscapeParameterValue([String]$InputObject) {
11-
Return ([GitHubActionsCommand]::EscapeValue($InputObject) -ireplace ',', '%2C' -ireplace ':', '%3A')
12-
}
13-
Static [String]EscapePropertyValue([String]$InputObject) {
14-
Return [GitHubActionsCommand]::EscapeParameterValue($InputObject)
3+
<#
4+
.SYNOPSIS
5+
GitHub Actions (Internal) - Format Command Parameter Value
6+
.DESCRIPTION
7+
Format command parameter value characters that can cause issues.
8+
.PARAMETER InputObject
9+
String that need to format command parameter value characters.
10+
.OUTPUTS
11+
[String] A string that formatted command parameter value characters.
12+
#>
13+
Function Format-CommandParameterValue {
14+
[CmdletBinding()]
15+
[OutputType([String])]
16+
Param (
17+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyString()][Alias('Input', 'Object')][String]$InputObject
18+
)
19+
Begin {}
20+
Process {
21+
Return ((Format-CommandValue -InputObject $InputObject) -ireplace ',', '%2C' -ireplace ':', '%3A')
1522
}
16-
Static [String]EscapeValue([String]$InputObject) {
23+
End {}
24+
}
25+
Set-Alias -Name 'Format-CommandPropertyValue' -Value 'Format-CommandParameterValue' -Option 'ReadOnly' -Scope 'Local'
26+
<#
27+
.SYNOPSIS
28+
GitHub Actions (Internal) - Format Command Value
29+
.DESCRIPTION
30+
Format command value characters that can cause issues.
31+
.PARAMETER InputObject
32+
String that need to format command value characters.
33+
.OUTPUTS
34+
[String] A string that formatted command value characters.
35+
#>
36+
Function Format-CommandValue {
37+
[CmdletBinding()]
38+
[OutputType([String])]
39+
Param (
40+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyString()][Alias('Input', 'Object')][String]$InputObject
41+
)
42+
Begin {}
43+
Process {
1744
Return ($InputObject -ireplace '%', '%25' -ireplace '\n', '%0A' -ireplace '\r', '%0D')
1845
}
46+
End {}
1947
}
48+
Set-Alias -Name 'Format-CommandContent' -Value 'Format-CommandValue' -Option 'ReadOnly' -Scope 'Local'
49+
Set-Alias -Name 'Format-CommandMessage' -Value 'Format-CommandValue' -Option 'ReadOnly' -Scope 'Local'
2050
<#
2151
.SYNOPSIS
2252
GitHub Actions - Write Command
@@ -42,8 +72,8 @@ Function Write-Command {
4272
Begin {}
4373
Process {
4474
Write-Host -Object "::$Command$(($Parameter.Count -igt 0) ? " $($Parameter.GetEnumerator() | Sort-Object -Property 'Name' | ForEach-Object -Process {
45-
Return "$($_.Name)=$([GitHubActionsCommand]::EscapeParameterValue($_.Value))"
46-
} | Join-String -Separator ',')" : '')::$([GitHubActionsCommand]::EscapeValue($Value))"
75+
Return "$($_.Name)=$(Format-CommandParameterValue -InputObject $_.Value)"
76+
} | Join-String -Separator ',')" : '')::$(Format-CommandValue -InputObject $Value)"
4777
}
4878
End {}
4979
}

hugoalh.GitHubActionsToolkit/module/command-control.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Function Test-ProcessingCommandsEndToken {
182182
[CmdletBinding()]
183183
[OutputType([Boolean])]
184184
Param (
185-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyString()][Alias('Input', 'Object')][String]$InputObject
185+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][Alias('Input', 'Object')][String]$InputObject
186186
)
187187
Begin {}
188188
Process {

hugoalh.GitHubActionsToolkit/module/environment-variable.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Function Test-EnvironmentVariableName {
158158
[CmdletBinding()]
159159
[OutputType([Boolean])]
160160
Param (
161-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyString()][Alias('Input', 'Object')][String]$InputObject
161+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][Alias('Input', 'Object')][String]$InputObject
162162
)
163163
Begin {}
164164
Process {

hugoalh.GitHubActionsToolkit/module/nodejs-test.psm1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ Function Test-NodeJsEnvironment {
2525
[Alias('Reinstall', 'ReinstallDependency', 'ReinstallPackage', 'ReinstallPackages')][Switch]$ReinstallDependencies,
2626
[Alias('Redo')][Switch]$Retest
2727
)
28-
If ($EnvironmentTested -and !$Retest.IsPresent) {
28+
If ($EnvironmentTested -and !$ReinstallDependencies.IsPresent -and !$Retest.IsPresent) {
2929
Write-Verbose -Message 'Previously tested NodeJS environment; Return previous result.'
3030
Return $EnvironmentResult
3131
}
32-
$EnvironmentTested = $False
32+
$Script:EnvironmentTested = $False
3333
Try {
3434
Write-Verbose -Message 'Test NodeJS.'
35-
Get-Command -Name 'node' -CommandType 'Application' | Out-Null# `Get-Command` always throw error when nothing is found.
35+
Get-Command -Name 'node' -CommandType 'Application' -ErrorAction 'Stop' | Out-Null# `Get-Command` will throw error when nothing is found.
3636
[String]$GetNodeJsVersionRawResult = (Invoke-Expression -Command 'node --no-deprecation --no-warnings --version' | Join-String -Separator "`n").Trim()
3737
If (
3838
$GetNodeJsVersionRawResult -inotmatch $SemVerRegEx -or
@@ -41,7 +41,7 @@ Function Test-NodeJsEnvironment {
4141
Throw
4242
}
4343
Write-Verbose -Message 'Test NPM.'
44-
Get-Command -Name 'npm' -CommandType 'Application' | Out-Null# `Get-Command` always throw error when nothing is found.
44+
Get-Command -Name 'npm' -CommandType 'Application' -ErrorAction 'Stop' | Out-Null# `Get-Command` will throw error when nothing is found.
4545
[String[]]$GetNpmVersionRawResult = Invoke-Expression -Command 'npm --version'# NPM sometimes display other useless things which unable to suppress.
4646
If (
4747
$GetNpmVersionRawResult -inotmatch $SemVerRegEx -or
@@ -50,9 +50,9 @@ Function Test-NodeJsEnvironment {
5050
Throw
5151
}
5252
} Catch {
53-
$EnvironmentTested = $True
54-
$EnvironmentResult = $False
55-
Return $False
53+
$Script:EnvironmentTested = $True
54+
$Script:EnvironmentResult = $False
55+
Return $EnvironmentResult
5656
}
5757
[String]$OriginalWorkingDirectory = (Get-Location).Path
5858
Write-Verbose -Message 'Test NodeJS dependencies.'
@@ -71,14 +71,14 @@ Function Test-NodeJsEnvironment {
7171
}
7272
} Catch {
7373
Set-Location -LiteralPath $OriginalWorkingDirectory
74-
$EnvironmentTested = $True
75-
$EnvironmentResult = $False
76-
Return $False
74+
$Script:EnvironmentTested = $True
75+
$Script:EnvironmentResult = $False
76+
Return $EnvironmentResult
7777
}
7878
Set-Location -LiteralPath $OriginalWorkingDirectory
79-
$EnvironmentTested = $True
80-
$EnvironmentResult = $True
81-
Return $True
79+
$Script:EnvironmentTested = $True
80+
$Script:EnvironmentResult = $True
81+
Return $EnvironmentResult
8282
}
8383
Export-ModuleMember -Function @(
8484
'Test-NodeJsEnvironment'

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/package-lock.json

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

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@actions/artifact": "^1.1.0",
25-
"@actions/cache": "^3.0.0",
25+
"@actions/cache": "^3.0.1",
2626
"@actions/core": "^1.9.0",
2727
"@actions/tool-cache": "^2.0.1"
2828
},

hugoalh.GitHubActionsToolkit/module/step-summary.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Function Set-StepSummary {
283283
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_set-githubactionsstepsummary#Set-GitHubActionsStepSummary')]
284284
[OutputType([Void])]
285285
Param (
286-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyCollection()][Alias('Content')][String[]]$Value,
286+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][AllowEmptyCollection()][AllowEmptyString()][AllowNull()][Alias('Content')][String[]]$Value,
287287
[Switch]$NoNewLine
288288
)
289289
Begin {

0 commit comments

Comments
 (0)