Modules/businessdev.ALbuild.Apps/Private/Resolve-BcCallGraphPath.ps1
|
function Resolve-BcCallGraphPath { <# .SYNOPSIS Resolves a call graph given as its folder or its graph.jsonl into the files that belong to it. .OUTPUTS PSCustomObject: Folder, GraphPath, AppsPath, AnalysisPath (each $null when absent). #> [CmdletBinding()] [OutputType([PSCustomObject])] param( [Parameter(Mandatory)] [string] $Path, [switch] $Require ) if (-not (Test-Path -LiteralPath $Path)) { if ($Require) { throw "Call graph not found: '$Path'." } return $null } $item = Get-Item -LiteralPath $Path $folder = if ($item.PSIsContainer) { $item.FullName } else { $item.DirectoryName } $graph = if ($item.PSIsContainer) { Join-Path $folder 'graph.jsonl' } else { $item.FullName } if (-not (Test-Path -LiteralPath $graph)) { if ($Require) { throw "No graph.jsonl in '$folder'. Build one with New-BcCallGraph." } return $null } $apps = Join-Path $folder 'apps.json' $analysis = Join-Path $folder 'analysis.json' [PSCustomObject]@{ Folder = $folder GraphPath = $graph AppsPath = if (Test-Path -LiteralPath $apps) { $apps } else { $null } AnalysisPath = if (Test-Path -LiteralPath $analysis) { $analysis } else { $null } } } |