implements nvm which
parent
afba4e08fd
commit
382c3aa85e
35
nvm.sh
35
nvm.sh
|
@ -547,6 +547,7 @@ nvm() {
|
||||||
echo " nvm unalias <name> Deletes the alias named <name>"
|
echo " nvm unalias <name> Deletes the alias named <name>"
|
||||||
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
|
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
|
||||||
echo " nvm unload Unload NVM from shell"
|
echo " nvm unload Unload NVM from shell"
|
||||||
|
echo " nvm which [<version>] Display path to installed node version"
|
||||||
echo
|
echo
|
||||||
echo "Example:"
|
echo "Example:"
|
||||||
echo " nvm install v0.10.24 Install a specific version number"
|
echo " nvm install v0.10.24 Install a specific version number"
|
||||||
|
@ -949,6 +950,40 @@ nvm() {
|
||||||
"current" )
|
"current" )
|
||||||
nvm_version current
|
nvm_version current
|
||||||
;;
|
;;
|
||||||
|
"which" )
|
||||||
|
INPUT=$2
|
||||||
|
|
||||||
|
if [ "_$2" != '_system' ]; then
|
||||||
|
VERSION="$(nvm_version "$INPUT")"
|
||||||
|
else
|
||||||
|
VERSION="$INPUT"
|
||||||
|
fi
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
nvm help
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "_$VERSION" = '_system' ]; then
|
||||||
|
if nvm_has_system_node && nvm deactivate >/dev/null 2>&1; then
|
||||||
|
echo $(dirname `which node`)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
echo "System version of node not found." >&2
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
|
elif [ "_$VERSION" = "_∞" ]; then
|
||||||
|
echo "The alias \"$2\" leads to an infinite loop. Aborting." >&2
|
||||||
|
return 8
|
||||||
|
fi
|
||||||
|
|
||||||
|
local NVM_VERSION_DIR
|
||||||
|
NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
|
||||||
|
if [ ! -d "$NVM_VERSION_DIR" ]; then
|
||||||
|
echo "$VERSION version is not installed yet" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo $NVM_DIR/$VERSION
|
||||||
|
;;
|
||||||
"alias" )
|
"alias" )
|
||||||
mkdir -p "$NVM_DIR/alias"
|
mkdir -p "$NVM_DIR/alias"
|
||||||
if [ $# -le 2 ]; then
|
if [ $# -le 2 ]; then
|
||||||
|
|
Loading…
Reference in New Issue