Address code quality

This commit is contained in:
Reinier Criel 2026-04-13 13:45:20 -07:00
parent 38a8130f4a
commit 8dbeab8dac

View file

@ -57,14 +57,28 @@ function Get-SafeChainCommand {
return Get-Command safe-chain -ErrorAction SilentlyContinue | Select-Object -First 1 return Get-Command safe-chain -ErrorAction SilentlyContinue | Select-Object -First 1
} }
function Get-ReportedInstallDir { function Get-ValidatedSafeChainCommandPath {
$command = Get-SafeChainCommand $command = Get-SafeChainCommand
if (-not $command) { if (-not $command -or [string]::IsNullOrWhiteSpace($command.Path)) {
return $null
}
$installDir = Get-InstallDirFromBinaryPath -BinaryPath $command.Path
if (-not $installDir) {
return $null
}
return $command.Path
}
function Get-ReportedInstallDir {
$safeChainPath = Get-ValidatedSafeChainCommandPath
if (-not $safeChainPath) {
return $null return $null
} }
try { try {
$reportedInstallDir = & safe-chain get-install-dir 2>$null | Select-Object -First 1 $reportedInstallDir = & $safeChainPath get-install-dir 2>$null | Select-Object -First 1
if ($reportedInstallDir) { if ($reportedInstallDir) {
$reportedInstallDir = $reportedInstallDir.Trim() $reportedInstallDir = $reportedInstallDir.Trim()
} }
@ -110,12 +124,7 @@ function Find-SafeChainBinary {
return $safeChainBin return $safeChainBin
} }
$command = Get-SafeChainCommand return Get-ValidatedSafeChainCommandPath
if ($command) {
return $command.Source
}
return $null
} }
function Invoke-SafeChainTeardown { function Invoke-SafeChainTeardown {