public/Get-WpcPipelineSourceFiles.ps1
|
function Get-WpcPipelineSourceFiles { param( [Parameter(Mandatory = $true)] [string] $SourceDir ) $pipelineSourceFiles = [System.Collections.Generic.List[System.IO.FileInfo]]::new() $topLevelSourceFiles = Get-ChildItem -Path $SourceDir -Filter '*.yml' -File | Where-Object { -not $_.Name.StartsWith('_') } foreach ($topLevelSourceFile in $topLevelSourceFiles) { $pipelineSourceFiles.Add($topLevelSourceFile) } $pipelinesDir = Join-Path $SourceDir '_pipelines' if (-not (Test-Path $pipelinesDir)) { return @($pipelineSourceFiles) } $nestedSourceFiles = Get-ChildItem -Path $pipelinesDir -Filter '*.yml' -File -Recurse | Where-Object { if ($_.Name.StartsWith('_')) { return $false } $relativePath = Get-WpcRelativeSourcePath -SourceDir $pipelinesDir -SourceFilePath $_.FullName $pathSegments = $relativePath.Split('/') return -not ($pathSegments | Where-Object { $_.StartsWith('_') }) } foreach ($nestedSourceFile in $nestedSourceFiles) { $pipelineSourceFiles.Add($nestedSourceFile) } return @($pipelineSourceFiles | Sort-Object FullName -Unique) } |