Always sets GOENV_ROOT. Bailes early if goenv not found
parent
fc43b112a5
commit
d24ab02be5
|
|
@ -1,29 +1,23 @@
|
||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'Init goenv, if installed. Plays nicely with package managers'
|
about-plugin 'Init goenv, if installed. Plays nicely with package managers'
|
||||||
|
|
||||||
# GOENV_ROOT does not need to be configured.
|
# Look for goenv command
|
||||||
# If it is configured, it should not be overridden.
|
if ! _command_exists goenv ; then
|
||||||
# However, let's try to handle the case where:
|
# Add it to the path if we find it, bail otherwise
|
||||||
# - goenv is not already on the path
|
if [ -n "${GOENV_ROOT}" ] && [ -x "${GOENV_ROOT}/bin/goenv" ] ; then
|
||||||
# - GOENV_ROOT is not configured
|
pathmunge "${GOENV_ROOT}/bin"
|
||||||
# - User has installed goenv in ~/.goenv
|
elif [ -x "${HOME}/.goenv/bin/goenv" ]; then
|
||||||
# In this case, we'll do the user a solid and configure
|
pathmunge "${HOME}/.goenv/bin"
|
||||||
# the goenv they've taken the time to install.
|
else
|
||||||
if ! _command_exists goenv && [ -z "${GOENV_ROOT}" ] && [ -x "${HOME}/.goenv/bin/goenv" ]; then
|
return
|
||||||
export GOENV_ROOT="${HOME}/.goenv"
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add GOENV_ROOT/bin to path if:
|
# Use a reasonable default to ensure variable is always present
|
||||||
# - goenv not already on path
|
# NOTE: This (currently) matches goenv's built-in default
|
||||||
# - GOENV_ROOT is configured
|
export GOENV_ROOT="${GOENV_ROOT:-${HOME}/.goenv}"
|
||||||
# - User has installed goenv in GOENV_ROOT
|
|
||||||
if ! _command_exists goenv && [ -n "${GOENV_ROOT}" ] && [ -x "${GOENV_ROOT}/bin/goenv" ]; then
|
|
||||||
pathmunge "${GOENV_ROOT}/bin"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Initialize goenv - Play nicely if goenv never made it to the path
|
# Initialize goenv
|
||||||
# NOTE: In the off-chance that goenv has already been initialized,
|
# NOTE: In the off-chance that goenv has already been initialized,
|
||||||
# it should be safe to re-initialize
|
# it should be safe to re-initialize
|
||||||
if _command_exists goenv ; then
|
eval "$(goenv init - bash)"
|
||||||
eval "$(goenv init - bash)"
|
|
||||||
fi
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue