Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to nvm 0.12.0 #346

Merged
merged 1 commit into from
Jul 23, 2014
Merged
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
42 changes: 39 additions & 3 deletions ci_environment/nodejs/files/default/nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
fi

nvm_tree_contains_path() {
local tree
tree="$1"
local path
path="$2"
local pathdir
pathdir=$(dirname "$path")
while [ "$pathdir" != "" ] && [ "$pathdir" != "." ] && [ "$pathdir" != "/" ] && [ "$pathdir" != "$tree" ]; do
pathdir=$(dirname "$pathdir")
done
[ "$pathdir" = "$tree" ]
}

# Traverse up in directory tree to find containing folder
nvm_find_up() {
local path
Expand Down Expand Up @@ -147,7 +160,15 @@ nvm_binary_available() {
}

nvm_ls_current() {
echo `node -v 2>/dev/null`
local NODE_PATH
NODE_PATH="$(which node)"
if [ $? -ne 0 ]; then
echo 'none'
elif nvm_tree_contains_path "$NVM_DIR" "$NODE_PATH"; then
echo `node -v 2>/dev/null`
else
echo 'system'
fi
}

nvm_ls() {
Expand Down Expand Up @@ -181,6 +202,9 @@ nvm_ls() {
echo "N/A"
return 3
fi
if [ -z "$PATTERN" ] && nvm_has_system_node; then
VERSIONS="$VERSIONS$(printf '\n%s' 'system')"
fi
echo "$VERSIONS"
return
}
Expand Down Expand Up @@ -238,6 +262,8 @@ nvm_print_versions() {
FORMAT='\033[0;32m-> %9s\033[0m'
elif [ -d "$NVM_DIR/$VERSION" ]; then
FORMAT='\033[0;34m%12s\033[0m'
elif [ "$VERSION" = "system" ]; then
FORMAT='\033[0;33m%12s\033[0m'
else
FORMAT='%12s'
fi
Expand Down Expand Up @@ -524,7 +550,17 @@ nvm() {
VERSION=`nvm_version $NVM_RC_VERSION`
fi
else
VERSION=`nvm_version $2`
if [ $2 = 'system' ]; then
if nvm_has_system_node && nvm deactivate; then
echo "Now using system version of node: $(node -v 2>/dev/null)."
return
else
echo "System version of node not found." >&2
return 127
fi
else
VERSION=`nvm_version $2`
fi
fi
if [ -z "$VERSION" ]; then
nvm help
Expand Down Expand Up @@ -687,7 +723,7 @@ nvm() {
nvm_version $2
;;
"--version" )
echo "0.11.2"
echo "0.12.0"
;;
"unload" )
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version > /dev/null 2>&1
Expand Down