Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.
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
11 changes: 10 additions & 1 deletion bin/avn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ function __avn_chpwd() {
local file=$(__avn_find_file)
local dir=${file%/*}
local name=${file##*/}
local VERSION_REGEX="[0-9]+\.[0-9]+\.[0-9]+"

if [[ -n "$file" ]] && [[ "$file" != "$__avn_active_file" ]]; then
[[ $(node -v) =~ $VERSION_REGEX ]] && currentNodeVersion=${BASH_REMATCH}
[[ $(head -n 1 $file) =~ $VERSION_REGEX ]] && targetNodeVersion=${BASH_REMATCH}

# Abort if the current and target node versions are the same
# https://github.com/wbyoung/avn/issues/78
[[ $currentNodeVersion == $targetNodeVersion ]] && return 0

[[ -n "$file" ]] && [[ "$file" != "$__avn_active_file" ]] &&
__avn_eval chpwd "$dir" "$name" || true
fi

__avn_active_file=$file

Expand Down