Skip to content

Commit d5e6ca7

Browse files
Fix update-index lint warnings
Keep stage logging while moving variable usage out of LogGroup scriptblock scopes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 2a4d541 commit d5e6ca7

1 file changed

Lines changed: 41 additions & 39 deletions

File tree

.github/actions/update-index/src/Helper.psm1

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,26 @@ function Update-MDSection {
112112
[string] $Content
113113
)
114114

115-
LogGroup "Update markdown section [$Name] in [$Path]" {
116-
$startSegment = "<!-- $Name`_START -->"
117-
$endSegment = "<!-- $Name`_END -->"
118-
$currentContent = Get-Content -Path $Path
119-
$startIndex = $currentContent.IndexOf($startSegment)
120-
$endIndex = $currentContent.IndexOf($endSegment)
121-
122-
if ($startIndex -lt 0) {
123-
throw "[$Name] The start comment segment was not found in the file."
124-
}
125-
if ($endIndex -lt 0) {
126-
throw "[$Name] The end comment segment was not found in the file."
127-
}
128-
if ($endIndex -lt $startIndex) {
129-
throw "[$Name] The end comment segment was found before the start comment segment."
130-
}
115+
Write-Host "Preparing markdown section update [$Name] in [$Path]"
116+
$startSegment = "<!-- $Name`_START -->"
117+
$endSegment = "<!-- $Name`_END -->"
118+
$currentContent = Get-Content -Path $Path
119+
$startIndex = $currentContent.IndexOf($startSegment)
120+
$endIndex = $currentContent.IndexOf($endSegment)
121+
122+
if ($startIndex -lt 0) {
123+
throw "[$Name] The start comment segment was not found in the file."
124+
}
125+
if ($endIndex -lt 0) {
126+
throw "[$Name] The end comment segment was not found in the file."
127+
}
128+
if ($endIndex -lt $startIndex) {
129+
throw "[$Name] The end comment segment was found before the start comment segment."
130+
}
131131

132-
$updatedContent = $currentContent[0..$startIndex] + $Content + $currentContent[($endIndex)..($currentContent.Length - 1)]
133-
if ($PSCmdlet.ShouldProcess('Readme section', 'Update')) {
132+
$updatedContent = $currentContent[0..$startIndex] + $Content + $currentContent[($endIndex)..($currentContent.Length - 1)]
133+
if ($PSCmdlet.ShouldProcess('Readme section', 'Update')) {
134+
LogGroup "Update markdown section [$Name] in [$Path]" {
134135
Set-Content -Path $Path -Value $updatedContent
135136
Write-Host "Section [$Name] updated in [$Path]"
136137
}
@@ -663,33 +664,34 @@ function Update-ModuleList {
663664
[object[]] $Repos = @()
664665
)
665666

666-
LogGroup 'Prepare module catalog generation' {
667-
if ($Repos.Count -eq 0) {
667+
if ($Repos.Count -eq 0) {
668+
LogGroup 'Prepare module catalog generation' {
668669
Write-Host 'No repository list was provided, retrieving repositories now'
669-
$Repos = Show-RepoList
670670
}
671+
$Repos = Show-RepoList
672+
}
671673

672-
$moduleCatalogTemplateVersion = 'v2'
673-
$moduleCatalogTemplateFolder = Join-Path (Join-Path $PSScriptRoot '..') 'templates\module-catalog'
674-
$moduleCatalogRowTemplatePath = Join-Path $moduleCatalogTemplateFolder "$moduleCatalogTemplateVersion-row.html"
675-
$moduleCatalogTableTemplatePath = Join-Path $moduleCatalogTemplateFolder "$moduleCatalogTemplateVersion-table.html"
676-
$moduleCatalogRowTemplate = Get-TemplateContent -Path $moduleCatalogRowTemplatePath
677-
$moduleCatalogTableTemplate = Get-TemplateContent -Path $moduleCatalogTableTemplatePath
674+
$moduleCatalogTemplateVersion = 'v2'
675+
$moduleCatalogTemplateFolder = Join-Path (Join-Path $PSScriptRoot '..') 'templates\module-catalog'
676+
$moduleCatalogRowTemplatePath = Join-Path $moduleCatalogTemplateFolder "$moduleCatalogTemplateVersion-row.html"
677+
$moduleCatalogTableTemplatePath = Join-Path $moduleCatalogTemplateFolder "$moduleCatalogTemplateVersion-table.html"
678+
$moduleCatalogRowTemplate = Get-TemplateContent -Path $moduleCatalogRowTemplatePath
679+
$moduleCatalogTableTemplate = Get-TemplateContent -Path $moduleCatalogTableTemplatePath
680+
681+
$moduleRepos = $Repos | Where-Object {
682+
$_.Type -eq 'Module' -and $_.Owner -eq 'PSModule'
683+
} | Sort-Object Name
684+
$catalogFolderPath = Join-Path 'src\docs\Modules\Catalog' 'Repositories'
685+
if (-not (Test-Path $catalogFolderPath)) {
686+
Write-Host "Creating catalog folder [$catalogFolderPath]"
687+
$null = New-Item -Path $catalogFolderPath -ItemType Directory
688+
}
678689

679-
$moduleRepos = $Repos | Where-Object {
680-
$_.Type -eq 'Module' -and $_.Owner -eq 'PSModule'
681-
} | Sort-Object Name
690+
$processLatestVersion = Get-RepositoryVersion -Owner 'PSModule' -Name 'Process-PSModule'
691+
$moduleTableRows = ''
692+
LogGroup 'Prepare module catalog generation' {
682693
Write-Host "Module repositories to process: $($moduleRepos.Count)"
683-
684-
$catalogFolderPath = Join-Path 'src\docs\Modules\Catalog' 'Repositories'
685-
if (-not (Test-Path $catalogFolderPath)) {
686-
Write-Host "Creating catalog folder [$catalogFolderPath]"
687-
$null = New-Item -Path $catalogFolderPath -ItemType Directory
688-
}
689-
690-
$processLatestVersion = Get-RepositoryVersion -Owner 'PSModule' -Name 'Process-PSModule'
691694
Write-Host "Latest Process-PSModule version: $processLatestVersion"
692-
$moduleTableRows = ''
693695
}
694696

695697
$moduleRepoTotal = $moduleRepos.Count

0 commit comments

Comments
 (0)