Updates from review feedback.
* Don't bail if GOENV_ROOT not set * Set GOENV_ROOT to ~/.goenv if not set and installed there * Only munge path if goenv not on path and exists in GOENV_ROOT/bin * More commentspull/1515/head
parent
73a21f7435
commit
fc43b112a5
|
|
@ -1,21 +1,29 @@
|
||||||
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'
|
||||||
|
|
||||||
# Try to set GOENV_ROOT if not already set
|
# GOENV_ROOT does not need to be configured.
|
||||||
if [ -z "${GOENV_ROOT}" ]; then
|
# If it is configured, it should not be overridden.
|
||||||
# Bail if cannot be set
|
# However, let's try to handle the case where:
|
||||||
if [ ! -d "$HOME/.goenv" ]; then
|
# - goenv is not already on the path
|
||||||
return
|
# - GOENV_ROOT is not configured
|
||||||
fi
|
# - User has installed goenv in ~/.goenv
|
||||||
export GOENV_ROOT="$HOME/.goenv"
|
# In this case, we'll do the user a solid and configure
|
||||||
|
# the goenv they've taken the time to install.
|
||||||
|
if ! _command_exists goenv && [ -z "${GOENV_ROOT}" ] && [ -x "${HOME}/.goenv/bin/goenv" ]; then
|
||||||
|
export GOENV_ROOT="${HOME}/.goenv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add GOENV_ROOT/bin to path if goenv not already on path
|
# Add GOENV_ROOT/bin to path if:
|
||||||
if ! _command_exists goenv && [ -x "${GOENV_ROOT}/bin/goenv" ]; then
|
# - goenv not already on path
|
||||||
pathmunge "$GOENV_ROOT/bin"
|
# - GOENV_ROOT is configured
|
||||||
|
# - 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
|
fi
|
||||||
|
|
||||||
# Initialize goenv - Play nicely if goenv not on path
|
# Initialize goenv - Play nicely if goenv never made it to the path
|
||||||
|
# NOTE: In the off-chance that goenv has already been initialized,
|
||||||
|
# it should be safe to re-initialize
|
||||||
if _command_exists goenv ; then
|
if _command_exists goenv ; then
|
||||||
eval "$(goenv init - bash)"
|
eval "$(goenv init - bash)"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue