mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Address code quality
This commit is contained in:
parent
38a8130f4a
commit
8dbeab8dac
1 changed files with 18 additions and 9 deletions
|
|
@ -57,14 +57,28 @@ function Get-SafeChainCommand {
|
|||
return Get-Command safe-chain -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
}
|
||||
|
||||
function Get-ReportedInstallDir {
|
||||
function Get-ValidatedSafeChainCommandPath {
|
||||
$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
|
||||
}
|
||||
|
||||
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) {
|
||||
$reportedInstallDir = $reportedInstallDir.Trim()
|
||||
}
|
||||
|
|
@ -110,12 +124,7 @@ function Find-SafeChainBinary {
|
|||
return $safeChainBin
|
||||
}
|
||||
|
||||
$command = Get-SafeChainCommand
|
||||
if ($command) {
|
||||
return $command.Source
|
||||
}
|
||||
|
||||
return $null
|
||||
return Get-ValidatedSafeChainCommandPath
|
||||
}
|
||||
|
||||
function Invoke-SafeChainTeardown {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue