Skip to content

Commit

Permalink
Use return codes from poetry_venv to disabiguate causes of returns. (#22
Browse files Browse the repository at this point in the history
)

* resolve annoying message when pyproject= isn't set in mise.toml

* disambiguate "failures" of poetry_venv

* remove redundant check on VIRTUAL_ENV

* replace exit code 2 with 1
  • Loading branch information
chris-lingwood-korelabs-co authored Nov 21, 2024
1 parent c1aea14 commit daaaab6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion bin/exec-env
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ setup_virtualenv() {
return
fi

set +e
VIRTUAL_ENV="$(poetry_venv)"
if [[ -z "$VIRTUAL_ENV" ]] || [[ ! -d "$VIRTUAL_ENV" ]]; then
poetry_venv_exit_code=$?
set -e

if [[ $poetry_venv_exit_code -eq 1 ]]; then
return
fi

if [[ ! -d "$VIRTUAL_ENV" ]]; then
if [[ "${MISE_POETRY_AUTO_INSTALL:-}" != "true" ]] && [[ "${MISE_POETRY_AUTO_INSTALL:-}" != "1" ]]; then
echoerr "mise-poetry: Virtualenv does not exist at $VIRTUAL_ENV. Execute \`poetry install\` to create one."
return
Expand Down
4 changes: 2 additions & 2 deletions bin/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ poetry_venv() {
local pyproject
pyproject="$(eval "echo ${MISE_TOOL_OPTS__PYPROJECT-}")"
if [ "$pyproject" = "" ]; then
return
return 1
fi
if [[ $pyproject != /* ]] && [[ -n ${MISE_PROJECT_ROOT-} ]]; then
pyproject="${MISE_PROJECT_ROOT-}/$pyproject"
fi
if [[ ! -f $pyproject ]]; then
echoerr "mise-poetry: No pyproject.toml found. Execute \`poetry init\` to create \`$pyproject\` first."
return
return 1
fi
poetry_bin -C "${pyproject%/*}" env info --path 2>/dev/null
true
Expand Down

0 comments on commit daaaab6

Please sign in to comment.