Skip to content

Commit

Permalink
Adding support for homebrew tap url
Browse files Browse the repository at this point in the history
  • Loading branch information
emilhdiaz committed Oct 21, 2020
1 parent 7c387fe commit 40fdd0c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion libexec/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ install_packages_from_config() {
local INSTALLER=${INSTALLER:-$(get_default_os_package_manager)}
local VERSION=$(yq r "${CONFIG}" "packages[$_i].version")
local TAP=$(yq r "${CONFIG}" "packages[$_i].tap")
local TAP_URL=$(yq r "${CONFIG}" "packages[$_i].tap-url")

log_info "Found package ${YELLOW}${INSTALLER}:${PACKAGE}@${VERSION}${NC} in configuration file"

Expand All @@ -77,7 +78,9 @@ install_packages_from_config() {
install_or_upgrade_package "$(get_default_os_package_manager)" "${REQUIRED_PACKAGE}"
done

install_or_upgrade_package "${INSTALLER}" "${PACKAGE}" "${VERSION}" $([ -n "${TAP}" ] && echo "--tap ${TAP}")
install_or_upgrade_package "${INSTALLER}" "${PACKAGE}" "${VERSION}" \
$([ -n "${TAP}" ] && echo "--tap ${TAP}") \
$([ -n "${TAP_URL}" ] && echo "--tap-url ${TAP_URL}")
echo "\n"
done
}
Expand Down
3 changes: 2 additions & 1 deletion libexec/installers/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ brew_install_or_upgrade_package() {

local PROGRAM=$1 && shift
local TAP=$(parse_long_opt 'tap' '' "$@")
local TAP_URL=$(parse_long_opt 'tap-url' '' "$@")
local DESIRED_FORMULA=${1:-latest}
local CURRENT_VERSION=$(brew_get_current_version "${PROGRAM}")
local DESIRED_VERSION=${CURRENT_VERSION}

# check if we need to register plugin
if [ -n "${TAP}" ] && ! (brew tap | grep "${TAP}" > /dev/null 2>&1); then
log_info "ℹ️️ Installing homebrew tap ${TAP}..."
brew tap "${TAP}"
brew tap "${TAP}" "${TAP_URL}"
fi

# resolve "latest" version
Expand Down
5 changes: 4 additions & 1 deletion libexec/installers/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ install_or_upgrade_package() {
local PROGRAM=$1 && shift
local VERSION=${1:-}
local TAP=$(parse_long_opt 'tap' '' "$@")
local TAP_URL=$(parse_long_opt 'tap-url' '' "$@")

if [ -n "${DRY_RUN}" ]; then
return
Expand All @@ -87,7 +88,9 @@ install_or_upgrade_package() {

# install via brew
elif [[ "$INSTALLER" == "brew" ]]; then
brew_install_or_upgrade_package "${PROGRAM}" "${VERSION}" $([ -n "${TAP}" ] && echo "--tap ${TAP}")
brew_install_or_upgrade_package "${PROGRAM}" "${VERSION}" \
$([ -n "${TAP}" ] && echo "--tap ${TAP}") \
$([ -n "${TAP_URL}" ] && echo "--tap-url ${TAP_URL}")

# install via asdf
elif [[ "$INSTALLER" == "asdf" ]]; then
Expand Down

0 comments on commit 40fdd0c

Please sign in to comment.