Skip to content

Commit

Permalink
Remove the versions directory when the last version is uninstalled
Browse files Browse the repository at this point in the history
  • Loading branch information
e-nomem committed Jul 27, 2019
1 parent c3f5d5e commit 0a43afe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions libexec/tfenv-uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ dst_path="${TFENV_ROOT}/versions/${version}"
if [ -f "${dst_path}/terraform" ]; then
info "Uninstall Terraform v${version}"
rm -r "${dst_path}"
rmdir "${TFENV_ROOT}/versions" 2> /dev/null
info "\033[0;32mTerraform v${version} is successfully uninstalled\033[0;39m"
fi
12 changes: 12 additions & 0 deletions test/test_uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ v="$(tfenv list-remote | grep 0.8 | head -n 1)"
check_version "${v}" && exit 1 || exit 0
) || error_and_proceed "Uninstalling latest version "${v}" with Regex"

echo "### Uninstall removes versions directory"
cleanup || error_and_die "Cleanup failed?!"
(
tfenv install 0.12.1 || exit 1
tfenv install 0.12.2 || exit 1
[ -d "./versions" ] || exit 1
tfenv uninstall 0.12.1 || exit 1
[ -d "./versions" ] || exit 1
tfenv uninstall 0.12.2 || exit 1
[ -d "./versions" ] && exit 1 || exit 0
) || error_and_proceed "Removing last version deletes versions directory"

if [ "${#errors[@]}" -gt 0 ]; then
echo -e "\033[0;31m===== The following list tests failed =====\033[0;39m" >&2
for error in "${errors[@]}"; do
Expand Down

0 comments on commit 0a43afe

Please sign in to comment.