Skip to content
Myr

`nvm alias`: slightly speed up alias resolution.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jordan Harband · committed by Jordan Harband · parent 886cde7 · Browse files · 1 file+11 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−9 removed

  • other:+11 added−9 removed

1 file+11 added−9 removed

modified:nvm.sh+11 added-9 removed
389 unmodified lines
390}391392nvm_alias() {393 local ALIAS394 ALIAS="$1"394 ALIAS="${1-}"395 if [ -z "$ALIAS" ]; then396 echo >&2 'An alias is required.'397 return 1398 fi
1859 unmodified lines
2258 NVM_ALIAS_DIR="$(nvm_alias_path)"2259 command mkdir -p "$NVM_ALIAS_DIR"2260 if [ $# -le 2 ]; then2261 local DEST2262 local ALIAS2263 local ALIAS_PATH2262 for ALIAS_PATH in "$NVM_ALIAS_DIR"/"${2-}"*; do2263 ALIAS="$(command basename "$ALIAS_PATH")"2264 for ALIAS_PATH in "$NVM_ALIAS_DIR/${2-}"*; do2265 ALIAS="${ALIAS_PATH/$NVM_ALIAS_DIR\//}"2266 DEST="$(nvm_alias "$ALIAS" 2> /dev/null)"2267 if [ -n "$DEST" ]; then2268 VERSION="$(nvm_version "$DEST")"2269 if [ "_$DEST" = "_$VERSION" ]; then
22 unmodified lines
2292 return2293 fi2294 if [ -z "${3-}" ]; then2295 command rm -f "$NVM_ALIAS_DIR/$2"2294 echo "$2 -> *poof*"2296 echo "${2-} -> *poof*"2297 return2298 fi2297 VERSION="$(nvm_version "$3")"2299 VERSION="$(nvm_version "${3-}")"2300 if [ $? -ne 0 ]; then2299 echo "! WARNING: Version '$3' does not exist." >&22301 echo "! WARNING: Version '${3-}' does not exist." >&22302 fi2301 echo "$3" | tee "$NVM_ALIAS_DIR/$2" >/dev/null2303 echo "$3" | tee "$NVM_ALIAS_DIR/${2-}" >/dev/null2304 if [ ! "_$3" = "_$VERSION" ]; then2303 echo "$2 -> $3 (-> $VERSION)"2305 echo "${2-} -> ${3-} (-> $VERSION)"2306 else2305 echo "$2 -> $3"2307 echo "${2-} -> ${3-}"2308 fi2309 ;;2310 "unalias" )2311 local NVM_ALIAS_DIR
156 unmodified lines