ps/Modules/Cole.PowerShell.Developer/Public/Find-GitExecutablePath.ps1
2023-05-30 22:51:22 -07:00

29 lines
679 B
PowerShell

function Find-GitExecutablePath {
<#
.SYNOPSIS
Find the git executable path on this system
#>
param ()
$logLead = (Get-LogLeadName)
$path = (Get-Command git).Source
$isMissing = [string]::IsNullOrWhiteSpace($path)
$defaultPaths = @('C:\Program Files\git\bin\git.exe','C:\Program Files (x86)\git\bin\git.exe')
if (!$isMissing) {
return $path
}
foreach ($defaultPath in $defaultPaths) {
$path = $defaultPath
if (Test-Path -Path $path) {
return $path
}
}
# We didn't hit a return statement, therefore this is missing
throw "$logLead : Can not find an installed/in-path git command"
}