private/Resolve-JaxRepoRootedPath.ps1
|
function Resolve-JaxRepoRootedPath { param( [Parameter(Mandatory = $true)] [string] $Path, [string] $RepoRoot, [string] $WorkingDir ) if ($Path.StartsWith('^/')) { if ([string]::IsNullOrWhiteSpace($RepoRoot)) { throw "RepoRoot is required to resolve git-rooted path '$Path'." } return (Join-Path $RepoRoot $Path.Substring(2)) } if ([IO.Path]::IsPathRooted($Path)) { return $Path } if (-not [string]::IsNullOrWhiteSpace($WorkingDir)) { return (Join-Path $WorkingDir $Path) } if (-not [string]::IsNullOrWhiteSpace($RepoRoot)) { return (Join-Path $RepoRoot $Path) } return $Path } |