Add iojs support to "install"
parent
dd3a3763ce
commit
952096d034
84
nvm.sh
84
nvm.sh
|
@ -643,12 +643,68 @@ nvm_get_arch() {
|
||||||
echo "$NVM_ARCH"
|
echo "$NVM_ARCH"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_install_iojs_binary() {
|
||||||
|
local PREFIXED_VERSION
|
||||||
|
PREFIXED_VERSION="$1"
|
||||||
|
local REINSTALL_PACKAGES_FROM
|
||||||
|
REINSTALL_PACKAGES_FROM="$2"
|
||||||
|
|
||||||
|
if ! nvm_is_iojs_version "$PREFIXED_VERSION"; then
|
||||||
|
echo 'nvm_install_iojs_binary requires an iojs-prefixed version.' >&2
|
||||||
|
return 10
|
||||||
|
fi
|
||||||
|
|
||||||
|
local VERSION
|
||||||
|
VERSION="$(nvm_strip_iojs_prefix "$PREFIXED_VERSION")"
|
||||||
|
local VERSION_PATH
|
||||||
|
VERSION_PATH="$(nvm_version_path "$PREFIXED_VERSION")"
|
||||||
|
local NVM_OS
|
||||||
|
NVM_OS="$(nvm_get_os)"
|
||||||
|
local t
|
||||||
|
local url
|
||||||
|
local sum
|
||||||
|
|
||||||
|
if [ -n "$NVM_OS" ]; then
|
||||||
|
if nvm_binary_available "$VERSION"; then
|
||||||
|
t="$VERSION-$NVM_OS-$(nvm_get_arch)"
|
||||||
|
url="$NVM_IOJS_ORG_MIRROR/$VERSION/$(nvm_iojs_prefix)-${t}.tar.gz"
|
||||||
|
sum="$(nvm_download -L -s $NVM_IOJS_ORG_MIRROR/$VERSION/SHASUMS256.txt -o - | command grep $(nvm_iojs_prefix)-${t}.tar.gz | command awk '{print $1}')"
|
||||||
|
local tmpdir
|
||||||
|
tmpdir="$NVM_DIR/bin/iojs-${t}"
|
||||||
|
local tmptarball
|
||||||
|
tmptarball="$tmpdir/iojs-${t}.tar.gz"
|
||||||
|
if (
|
||||||
|
command mkdir -p "$tmpdir" && \
|
||||||
|
nvm_download -L -C - --progress-bar $url -o "$tmptarball" && \
|
||||||
|
echo "WARNING: checksums are currently disabled for io.js" >&2 && \
|
||||||
|
# nvm_checksum "$tmptarball" $sum && \
|
||||||
|
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
|
command rm -f "$tmptarball" && \
|
||||||
|
command mkdir -p "$VERSION_PATH" && \
|
||||||
|
command mv "$tmpdir"/* "$VERSION_PATH"
|
||||||
|
); then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "Binary download failed, trying source." >&2
|
||||||
|
command rm -rf "$tmptarball" "$tmpdir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
|
||||||
nvm_install_node_binary() {
|
nvm_install_node_binary() {
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
local REINSTALL_PACKAGES_FROM
|
local REINSTALL_PACKAGES_FROM
|
||||||
REINSTALL_PACKAGES_FROM="$2"
|
REINSTALL_PACKAGES_FROM="$2"
|
||||||
|
|
||||||
|
if nvm_is_iojs_version "$PREFIXED_VERSION"; then
|
||||||
|
echo 'nvm_install_node_binary does not allow an iojs-prefixed version.' >&2
|
||||||
|
return 10
|
||||||
|
fi
|
||||||
|
|
||||||
local VERSION_PATH
|
local VERSION_PATH
|
||||||
VERSION_PATH="$(nvm_version_path "$VERSION")"
|
VERSION_PATH="$(nvm_version_path "$VERSION")"
|
||||||
local NVM_OS
|
local NVM_OS
|
||||||
|
@ -672,9 +728,9 @@ nvm_install_node_binary() {
|
||||||
nvm_checksum "$tmptarball" $sum && \
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
command rm -f "$tmptarball" && \
|
command rm -f "$tmptarball" && \
|
||||||
command mv "$tmpdir" "$VERSION_PATH"
|
command mkdir -p "$VERSION_PATH" && \
|
||||||
)
|
command mv "$tmpdir"/* "$VERSION_PATH"
|
||||||
then
|
); then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
echo "Binary download failed, trying source." >&2
|
echo "Binary download failed, trying source." >&2
|
||||||
|
@ -900,7 +956,7 @@ nvm() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NVM_IOJS
|
local NVM_IOJS
|
||||||
if nvm_is_iojs_version "$VERSION"; then
|
if nvm_is_iojs_version "$VERSION" || [ "_$VERSION" = "_$(nvm_iojs_prefix)" ]; then
|
||||||
NVM_IOJS=true
|
NVM_IOJS=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -912,8 +968,16 @@ nvm() {
|
||||||
nobinary=1
|
nobinary=1
|
||||||
fi
|
fi
|
||||||
# skip binary install if "nobinary" option specified.
|
# skip binary install if "nobinary" option specified.
|
||||||
if [ $nobinary -ne 1 ] && nvm_install_node_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then
|
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
|
||||||
if nvm use "$VERSION" \
|
local NVM_INSTALL_SUCCESS
|
||||||
|
if [ "$NVM_IOJS" = true ] && nvm_install_iojs_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then
|
||||||
|
NVM_INSTALL_SUCCESS=true
|
||||||
|
elif [ "$NVM_IOJS" != true ] && nvm_install_node_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then
|
||||||
|
NVM_INSTALL_SUCCESS=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NVM_INSTALL_SUCCESS" = true ] \
|
||||||
|
&& nvm use "$VERSION" \
|
||||||
&& [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
|
&& [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
|
||||||
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||||
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||||
|
@ -921,7 +985,13 @@ nvm() {
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_install_node_source "$VERSION" "$REINSTALL_PACKAGES_FROM" "$ADDITIONAL_PARAMETERS"
|
if [ "$NVM_IOJS" = true ]; then
|
||||||
|
# nvm_install_iojs_source "$VERSION" "$REINSTALL_PACKAGES_FROM" "$ADDITIONAL_PARAMETERS"
|
||||||
|
echo "Installing iojs from source is not currently supported" >&2
|
||||||
|
return 105
|
||||||
|
else
|
||||||
|
nvm_install_node_source "$VERSION" "$REINSTALL_PACKAGES_FROM" "$ADDITIONAL_PARAMETERS"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"uninstall" )
|
"uninstall" )
|
||||||
[ $# -ne 2 ] && nvm help && return
|
[ $# -ne 2 ] && nvm help && return
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message"
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
|
||||||
|
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install iojs-v1.0.0
|
||||||
|
nvm install iojs-v1.0.1
|
||||||
|
|
||||||
|
nvm use iojs-v1.0.0
|
||||||
|
|
||||||
|
node --version | grep v1.0.0 || die "precondition failed: iojs node doesn't start at v1.0.0"
|
||||||
|
iojs --version | grep v1.0.0 || die "precondition failed: iojs binary doesn't start at v1.0.0"
|
||||||
|
|
||||||
|
nvm install iojs-v1.0.1
|
||||||
|
|
||||||
|
node --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (node binary)"
|
||||||
|
iojs --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (iojs binary)"
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION="v1.0.0"
|
||||||
|
NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install $NVM_PREFIXED_TEST_VERSION || die "install $NVM_PREFIXED_TEST_VERSION failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../../versions/io.js/$NVM_TEST_VERSION ]
|
||||||
|
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
|
||||||
|
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install iojs-v1.0.0 || die "'nvm install iojs-v1.0.0' failed"
|
||||||
|
nvm i iojs-v1.0.1 || die "'nvm i iojs-v1.0.1' failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../../versions/io.js/v1.0.0 ] || die "iojs v1.0.0 didn't exist"
|
||||||
|
[ -d ../../../versions/io.js/v1.0.1 ] || die "iojs v1.0.1 didn't exist"
|
||||||
|
|
||||||
|
# Use the first one
|
||||||
|
nvm use iojs-1.0.0 || die "'nvm use iojs-1.0.0' failed"
|
||||||
|
|
||||||
|
# Use the latest one
|
||||||
|
nvm use iojs-1 || die "'nvm use iojs-1' failed"
|
||||||
|
[ "_$(node --version)" = "_v1.0.1" ] || die "'node --version' was not v1.0.1, got: $(node --version)"
|
||||||
|
[ "_$(iojs --version)" = "_v1.0.1" ] || die "'iojs --version' was not v1.0.1, got: $(iojs --version)"
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v1.0.0
|
||||||
|
NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"
|
||||||
|
VERSION_PATH="../../../versions/io.js/$NVM_TEST_VERSION"
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e $VERSION_PATH ] && rm -R $VERSION_PATH
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
echo "$NVM_PREFIXED_TEST_VERSION" > .nvmrc
|
||||||
|
|
||||||
|
nvm install || die "'nvm install' failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d $VERSION_PATH ] || die "./$VERSION_PATH did not exist"
|
||||||
|
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION \
|
||||||
|
|| "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
|
||||||
|
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install iojs-v1.0.0
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../../versions/io.js/v1.0.0 ] || die "nvm install iojs-v1.0.0 didn't install"
|
||||||
|
|
||||||
|
node --version | grep v1.0.0 > /dev/null || die "nvm install didn't use iojs-v1.0.0"
|
||||||
|
|
||||||
|
npm install -g is-nan@1.0.1 || die "npm install -g is-nan failed"
|
||||||
|
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||||
|
|
||||||
|
nvm ls iojs-1 | grep iojs-v1.0.0 > /dev/null || die "nvm ls iojs-1 didn't show iojs-v1.0.0"
|
||||||
|
|
||||||
|
nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 || die "nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 failed"
|
||||||
|
|
||||||
|
[ -d ../../../versions/io.js/v1.0.1 ] || die "nvm install iojs-v1.0.1 didn't install"
|
||||||
|
|
||||||
|
nvm use iojs-1
|
||||||
|
node --version | grep v1.0.1 > /dev/null || die "nvm use iojs-1 didn't use v1.0.1"
|
||||||
|
|
||||||
|
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -f ".nvmrc" ]; then
|
||||||
|
mv .nvmrc .nvmrc.bak
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm deactivate
|
||||||
|
nvm uninstall iojs-v1.0.0
|
||||||
|
|
||||||
|
if [ -f ".nvmrc" ]; then
|
||||||
|
rm .nvmrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f ".nvmrc.bak" ]; then
|
||||||
|
mv .nvmrc.bak .nvmrc
|
||||||
|
fi
|
||||||
|
|
|
@ -5,6 +5,6 @@ die () { echo $@ ; exit 1; }
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|
||||||
nvm install 0.6.21 || die 'v0.6.21 installation failed'
|
nvm install 0.6.21 || die 'v0.6.21 installation failed'
|
||||||
[ "$(node -v)" = "v0.6.21-pre" ] || die "v0.6.21-pre not installed with v0.6.21, got $(node -v)"
|
[ "_$(node -v)" = "_v0.6.21-pre" ] || die "v0.6.21-pre not installed with v0.6.21, got $(node -v)"
|
||||||
[ "$(nvm current)" = "v0.6.21" ] || die "v0.6.21-pre not reported as v0.6.21, got $(nvm current)"
|
[ "_$(nvm current)" = "_v0.6.21" ] || die "v0.6.21-pre not reported as v0.6.21, got $(nvm current)"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue