Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ export -f check_default_version;
function cleanup() {
log 'info' 'Performing cleanup';
local pwd="$(pwd)";

# Safety check to ensure TFENV_CONFIG_DIR is set and not empty
if [ -z "${TFENV_CONFIG_DIR:-""}" ]; then
log 'error' 'TFENV_CONFIG_DIR is not set, cannot perform cleanup safely';
return 1;
fi;

log 'debug' "Deleting ${TFENV_CONFIG_DIR}/version";
rm -rf "${TFENV_CONFIG_DIR}/version";
log 'debug' "Deleting ${TFENV_CONFIG_DIR}/version.prev";
Expand Down Expand Up @@ -200,6 +200,10 @@ function check_dependencies() {

log 'error' 'GNU Grep is a requirement and your Mac does not have it. Consider "brew install grep" or "nix profile install nixpkgs#gnugrep"';
fi;

if ! command -v unzip >/dev/null 2>&1; then
log 'error' 'unzip is a requirement and your device does not have it. Install unzip using your preferred method.';
fi;
};
export -f check_dependencies;

Expand Down