Check-Git.ps1 698 B

12345678910111213141516171819202122232425
  1. function Check-Git {
  2. <#
  3. .SYNOPSIS
  4. Ensures available git executable on host system.
  5. .DESCRIPTION
  6. Checks whether a git command is available on the host system. If none is found,
  7. Git is installed via winget.
  8. .EXAMPLE
  9. Check-Git
  10. #>
  11. if ( ! ( Test-Path function:Log-Info ) ) {
  12. . $PSScriptRoot/Logger.ps1
  13. }
  14. Log-Information 'Checking for Git executable...'
  15. if ( ! ( Get-Command git ) ) {
  16. Log-Warning 'No Git executable found. Will try to install via winget.'
  17. winget install git
  18. } else {
  19. Log-Debug "Git found at $(Get-Command git)."
  20. Log-Status "Git found."
  21. }
  22. }