diff --git a/bin/n b/bin/n index ae9ded1..a99bdbf 100755 --- a/bin/n +++ b/bin/n @@ -71,23 +71,27 @@ display_n_version() { echo $VERSION && exit 0 } +# +# Check for installed version, and populate $version +# + +check_current_version() { + if test `which node`; then + installed=`node --version` + installed=${installed:1:${#installed}} + fi +} + # # Display current node --version # and others installed. # display_versions() { - # Active version - local installed - if test `which node`; then - local installed=`node --version` - installed=${installed:1:${#installed}} - fi - - # Installed versions + check_current_version for file in $VERSIONS_DIR/*; do local version=${file##*/} - if test $version = $installed; then + if test "$version" = "$installed"; then echo " \033[32m*\033[0m $version" else echo " $version"