install.fairie/home/.chezmoiscripts/universal/run_onchange_before_09-install-gh.sh.tmpl
2023-11-05 02:59:47 +00:00

28 lines
920 B
Cheetah

{{- if (ne .host.distro.family "windows") -}}
#!/usr/bin/env bash
# @file GH (GitHub CLI) Install
# @brief Ensures GH (the GitHub CLI) is installed via Homebrew
# @description
# This script installs GH via Homebrew. GH is included as a dependency for
# generating the global git config helper since GH provides a credential
# helper that can be used to authenticate calls on `github.com`.
{{ includeTemplate "universal/profile-before" }}
{{ includeTemplate "universal/logg-before" }}
### Ensure gh is installed
if ! command -v gh > /dev/null; then
if command -v brew; then
logg 'Installing gh via Homebrew'
brew install gh || GH_EXIT_CODE=$?
if [ -n "$GH_EXIT_CODE" ]; then
logg error 'gh was not successfully installed via Homebrew'
fi
else
logg 'brew is unavailable. Cannot use it to perform a system installation of node.'
fi
else
logg 'gh is available'
fi
{{ end -}}