public/Convert-WpcRelativeSourcePathToOutputFileName.ps1
|
function Convert-WpcRelativeSourcePathToOutputFileName { param( [Parameter(Mandatory = $true)] [string] $RelativeSourcePath ) $relativePathWithoutExtension = $RelativeSourcePath -replace '\.yml$', '' $normalizedRelativePath = $relativePathWithoutExtension.Replace('\', '/').Trim('/') if ($normalizedRelativePath.StartsWith('_pipelines/')) { $normalizedRelativePath = $normalizedRelativePath.Substring('_pipelines/'.Length) } $nameParts = @($normalizedRelativePath.Split('/') | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) if ($nameParts.Count -eq 0) { throw "Could not derive output filename from relative source path '$RelativeSourcePath'." } return "$($nameParts -join '-').yaml" } |