Private/Resolve-KadenChildRoot.ps1
|
function Resolve-KadenChildRoot { <# .SYNOPSIS Resolve a child repository path against the PowerShell location. .DESCRIPTION .NET GetFullPath uses the process working directory, which is often C:\Windows\System32 when a module command runs. Relative paths, including '.', are resolved from Get-Location instead. #> [CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$Path ) if ([System.IO.Path]::IsPathRooted($Path)) { return [System.IO.Path]::GetFullPath($Path) } $location = Get-Location $base = if ($location.Provider -and $location.Provider.Name -eq 'FileSystem' -and $location.ProviderPath) { [string]$location.ProviderPath } else { [string]$location.Path } if ([string]::IsNullOrWhiteSpace($base)) { throw 'KDN-TXN-PREFLIGHT-FAILED: The current location is not a filesystem path.' } return [System.IO.Path]::GetFullPath((Join-Path $base $Path)) } |