Adding `nvm_version_dir`
parent
42786630a1
commit
9068dda110
13
nvm.sh
13
nvm.sh
|
@ -95,6 +95,19 @@ nvm_rc_version() {
|
|||
fi
|
||||
}
|
||||
|
||||
nvm_version_dir() {
|
||||
local NVM_USE_NEW_DIR
|
||||
NVM_USE_NEW_DIR="$1"
|
||||
if [ -z "$NVM_USE_NEW_DIR" ] || [ "$NVM_USE_NEW_DIR" = "new" ]; then
|
||||
echo "$NVM_DIR/versions"
|
||||
elif [ "$NVM_USE_NEW_DIR" = "old" ]; then
|
||||
echo "$NVM_DIR"
|
||||
else
|
||||
echo "unknown version dir" >&2
|
||||
return 3
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_version_path() {
|
||||
local VERSION
|
||||
VERSION="$1"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "$(nvm_version_dir)" = "$NVM_DIR/versions" ] || die '"nvm_version_dir" did not return new dir path'
|
||||
[ "$(nvm_version_dir new)" = "$(nvm_version_dir)" ] || die '"nvm_version_dir new" did not return new dir path'
|
||||
[ "$(nvm_version_dir old)" = "$NVM_DIR" ] || die '"nvm_version_dir old" did not return old dir path'
|
||||
[ "$(nvm_version_dir foo 2>&1)" = "unknown version dir" ] || die '"nvm_version_dir foo" did not error out'
|
||||
|
Loading…
Reference in New Issue