Use absolute version to install nightly and rc

POSIX sed doesn't do non-greddy match so we just pipe it to awk.
This will handle cases when the latest nighlty version is installed or not.

Command tested with.

echo "v10.0.0-nightly20171126bb4462681c            (test)"  \
	| sed -n "s/.*\(v.*\)/\1/p" | awk '{print $1}'

echo "-> v10.0.0-nightly20171126bb4462681c            (test)"  \
	| sed -n "s/.*\(v.*\)/\1/p" | awk '{print $1}'
This commit is contained in:
Cswl Coldwind 2017-11-23 00:55:27 +05:45
parent 2d88fd5c8f
commit f2e84ed7cf

View File

@ -176,23 +176,28 @@ _zsh_nvm_auto_use() {
} }
_zsh_nvm_install_wrapper() { _zsh_nvm_install_wrapper() {
case $2 in local extra_version
'rc') local nodejs_org_mirror
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc/ nvm install node && nvm alias rc "$(node --version)" local version_list
echo "Clearing mirror cache..." local version_latest
nvm ls-remote > /dev/null 2>&1
echo "Done!" if [[ $2 == 'rc' || $2 == 'nightly' ]]; then
;; extra_version=$2
'nightly') nodejs_org_mirror=https://nodejs.org/download/$extra_version/
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm install node && nvm alias nightly "$(node --version)" version_list="$(NVM_NODEJS_ORG_MIRROR=$nodejs_org_mirror nvm ls-remote |
echo "Clearing mirror cache..." tail -n 1)"
nvm ls-remote > /dev/null 2>&1 version_latest="$(echo "$version_list" \
echo "Done!" | sed -n "s/.*\(v.*\)/\1/p" \
;; | awk '{print $1}' )"
*) echo "Latest $extra_version: $version_latest."
_zsh_nvm_nvm "$@" NVM_NODEJS_ORG_MIRROR=$nodejs_org_mirror \
;; nvm install $version_latest && nvm alias $extra_version "$(node --version)"
esac echo "Clearing mirror cache..."
nvm ls-remote >/dev/null 2>&1
echo "Done!"
else
_zsh_nvm_nvm "$@"
fi
} }
# Don't init anything if this is true (debug/testing only) # Don't init anything if this is true (debug/testing only)