Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eb5561a

Browse files
authoredFeb 20, 2024
use inline (microsoft#930)
Co-authored-by: freddydk <[email protected]>
1 parent 547983e commit eb5561a

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed
 

‎Actions/Github-Helper.psm1

+3-1
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,9 @@ function Set-JsonContentLF {
727727
if ($PSVersionTable.PSVersion.Major -lt 6) {
728728
try {
729729
$path = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($path)
730-
. pwsh (Join-Path $PSScriptRoot 'prettyfyjson.ps1') $path
730+
# This command will reformat a JSON file with LF line endings as PowerShell 7 would do it (when run using pwsh)
731+
$command = "`$cr=[char]13;`$lf=[char]10;`$path='$path';`$content=Get-Content `$path -Encoding UTF8|ConvertFrom-Json|ConvertTo-Json -Depth 99;`$content=`$content -replace `$cr,'';`$content|Out-Host;[System.IO.File]::WriteAllText(`$path,`$content+`$lf)"
732+
. pwsh -command $command
731733
}
732734
catch {
733735
Write-Host "WARNING: pwsh (PowerShell 7) not installed, json will be formatted by PowerShell $($PSVersionTable.PSVersion)"

‎Actions/prettyfyjson.ps1

-10
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.