parent
49abc9ce02
commit
58ffa407c2
26
nvm.sh
26
nvm.sh
|
@ -24,7 +24,7 @@ nvm_get_latest() {
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
NVM_LATEST_URL="$(curl -q -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
NVM_LATEST_URL="$(curl -q -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||||
else
|
else
|
||||||
>&2 echo 'nvm needs curl or wget to proceed.'
|
>&2 echo 'nvm needs curl or wget to proceed.'
|
||||||
return 1
|
return 1
|
||||||
|
@ -33,7 +33,7 @@ nvm_get_latest() {
|
||||||
>&2 echo "http://latest.nvm.sh did not redirect to the latest release on Github"
|
>&2 echo "http://latest.nvm.sh did not redirect to the latest release on Github"
|
||||||
return 2
|
return 2
|
||||||
else
|
else
|
||||||
echo "$NVM_LATEST_URL" | awk -F'/' '{print $NF}'
|
echo "$NVM_LATEST_URL" | command awk -F'/' '{print $NF}'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ nvm_version() {
|
||||||
PATTERN="stable"
|
PATTERN="stable"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
VERSION="$(nvm_ls "$PATTERN" | tail -n1)"
|
VERSION="$(nvm_ls "$PATTERN" | command tail -n1)"
|
||||||
if [ -z "$VERSION" ] || [ "_$VERSION" = "_N/A" ]; then
|
if [ -z "$VERSION" ] || [ "_$VERSION" = "_N/A" ]; then
|
||||||
echo "N/A"
|
echo "N/A"
|
||||||
return 3;
|
return 3;
|
||||||
|
@ -254,14 +254,14 @@ nvm_remote_version() {
|
||||||
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
case "_$PATTERN" in
|
case "_$PATTERN" in
|
||||||
"_$(nvm_iojs_prefix)")
|
"_$(nvm_iojs_prefix)")
|
||||||
VERSION="$(nvm_ls_remote_iojs | tail -n1)"
|
VERSION="$(nvm_ls_remote_iojs | command tail -n1)"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
VERSION="$(nvm_ls_remote "$PATTERN")"
|
VERSION="$(nvm_ls_remote "$PATTERN")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
VERSION="$(nvm_remote_versions "$PATTERN" | tail -n1)"
|
VERSION="$(nvm_remote_versions "$PATTERN" | command tail -n1)"
|
||||||
fi
|
fi
|
||||||
echo "$VERSION"
|
echo "$VERSION"
|
||||||
if [ "_$VERSION" = '_N/A' ]; then
|
if [ "_$VERSION" = '_N/A' ]; then
|
||||||
|
@ -317,7 +317,7 @@ nvm_is_valid_version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_normalize_version() {
|
nvm_normalize_version() {
|
||||||
echo "${1#v}" | command awk -F. '{ printf("%d%06d%06d\n", $1,$2,$3); }'
|
echo "${1#v}" | command awk -F. '{ command printf("%d%06d%06d\n", $1,$2,$3); }'
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_ensure_version_prefix() {
|
nvm_ensure_version_prefix() {
|
||||||
|
@ -441,7 +441,7 @@ nvm_resolve_alias() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$ALIAS_TEMP" ] \
|
if [ -n "$ALIAS_TEMP" ] \
|
||||||
&& printf "$SEEN_ALIASES" | command grep -e "^$ALIAS_TEMP$" > /dev/null; then
|
&& command printf "$SEEN_ALIASES" | command grep -e "^$ALIAS_TEMP$" > /dev/null; then
|
||||||
ALIAS="∞"
|
ALIAS="∞"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -665,7 +665,7 @@ nvm_ls_remote() {
|
||||||
local GREP_OPTIONS
|
local GREP_OPTIONS
|
||||||
GREP_OPTIONS=''
|
GREP_OPTIONS=''
|
||||||
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
PATTERN="$(nvm_ls_remote "$(nvm_print_implicit_alias remote "$PATTERN")" | tail -n1)"
|
PATTERN="$(nvm_ls_remote "$(nvm_print_implicit_alias remote "$PATTERN")" | command tail -n1)"
|
||||||
elif [ -n "$PATTERN" ]; then
|
elif [ -n "$PATTERN" ]; then
|
||||||
PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
|
PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
|
||||||
else
|
else
|
||||||
|
@ -674,7 +674,7 @@ nvm_ls_remote() {
|
||||||
VERSIONS=`nvm_download -L -s $NVM_NODEJS_ORG_MIRROR/ -o - \
|
VERSIONS=`nvm_download -L -s $NVM_NODEJS_ORG_MIRROR/ -o - \
|
||||||
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
|
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
|
||||||
| command grep -w "${PATTERN}" \
|
| command grep -w "${PATTERN}" \
|
||||||
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
| command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
||||||
if [ -z "$VERSIONS" ]; then
|
if [ -z "$VERSIONS" ]; then
|
||||||
echo "N/A"
|
echo "N/A"
|
||||||
return 3
|
return 3
|
||||||
|
@ -757,7 +757,7 @@ nvm_print_versions() {
|
||||||
else
|
else
|
||||||
FORMAT='%15s'
|
FORMAT='%15s'
|
||||||
fi
|
fi
|
||||||
printf "$FORMAT\n" $VERSION
|
command printf "$FORMAT\n" $VERSION
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,7 +814,7 @@ nvm_print_implicit_alias() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NVM_IOJS_VERSION
|
local NVM_IOJS_VERSION
|
||||||
NVM_IOJS_VERSION="$($NVM_COMMAND | sed "s/^"$NVM_IMPLICIT"-//" | command grep -e '^v' | cut -c2- | cut -d . -f 1,2 | uniq | tail -1)"
|
NVM_IOJS_VERSION="$($NVM_COMMAND | sed "s/^"$NVM_IMPLICIT"-//" | command grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq | command tail -1)"
|
||||||
local EXIT_CODE
|
local EXIT_CODE
|
||||||
EXIT_CODE="$?"
|
EXIT_CODE="$?"
|
||||||
|
|
||||||
|
@ -841,7 +841,7 @@ nvm_print_implicit_alias() {
|
||||||
setopt shwordsplit
|
setopt shwordsplit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LAST_TWO=$($NVM_COMMAND | command grep -e '^v' | cut -c2- | cut -d . -f 1,2 | uniq)
|
LAST_TWO=$($NVM_COMMAND | command grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq)
|
||||||
|
|
||||||
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
||||||
unsetopt shwordsplit
|
unsetopt shwordsplit
|
||||||
|
@ -1693,7 +1693,7 @@ nvm() {
|
||||||
|
|
||||||
local NVM_OUTPUT
|
local NVM_OUTPUT
|
||||||
NVM_OUTPUT="$(echo "$NVM_LS_REMOTE_OUTPUT
|
NVM_OUTPUT="$(echo "$NVM_LS_REMOTE_OUTPUT
|
||||||
$NVM_LS_REMOTE_IOJS_OUTPUT" | command grep -v "N/A" | sed '/^$/d')"
|
$NVM_LS_REMOTE_IOJS_OUTPUT" | command grep -v "N/A" | command sed '/^$/d')"
|
||||||
if [ -n "$NVM_OUTPUT" ]; then
|
if [ -n "$NVM_OUTPUT" ]; then
|
||||||
nvm_print_versions "$NVM_OUTPUT"
|
nvm_print_versions "$NVM_OUTPUT"
|
||||||
return $NVM_LS_REMOTE_EXIT_CODE || $NVM_LS_REMOTE_IOJS_EXIT_CODE
|
return $NVM_LS_REMOTE_EXIT_CODE || $NVM_LS_REMOTE_IOJS_EXIT_CODE
|
||||||
|
|
Loading…
Reference in New Issue