Compare commits

..

14 Commits

Author SHA1 Message Date
Jordan Harband
e1c84bae37 v0.29.0 2015-10-09 01:52:19 -07:00
Jordan Harband
a928a8f181 nvm exec: don't fall back to .nvmrc when the provided version is not installed. 2015-10-08 17:37:53 -07:00
Jordan Harband
937c29c95a nvm run: use common code path for "ensure version installed"
Better than cb033adc6f
2015-10-08 16:48:17 -07:00
Jordan Harband
a0e94e16de Make sure nvm debug doesn't use an overridden sed 2015-10-08 00:19:53 -07:00
Jordan Harband
7028e5df19 Merge pull request #823 from jbergstroem/feature/prefer-xz
Support `xz` tarballs if available (on io.js >= 2.3.2 and node >= 4)
2015-10-08 00:19:35 -07:00
Johan Bergström
b8e4917646 Use xz tarballs if available
Saves us ~25% bandwidth while downloading the payload. This only applies
to hosts that has the `xz` binary and attempts to use iojs 2.3.2 or newer
(this includes nodejs 4.0+ as well). Older targets are unaffected.
2015-10-08 16:45:26 +11:00
Jordan Harband
cb033adc6f nvm run: use common code path for "ensure version installed" 2015-10-07 18:08:48 -07:00
Jordan Harband
20f4acdd25 [installing] echo the URL that the tarball is being downloaded from. 2015-10-07 20:28:18 -07:00
Jordan Harband
41153e207d Ensure nvm use output shows up *after* prefix check passes. 2015-10-07 14:40:31 -07:00
Jordan Harband
6b3c34313c Fix nvm_ls when $NVM_DIR has spaces in it.
Mostly fixes #861.
2015-10-07 13:57:29 -07:00
Jordan Harband
8541e2e1ee Properly quote some possible variables with spaces. 2015-10-07 13:57:13 -07:00
Jordan Harband
1efc8b4dbe Merge pull request #859 from fresheneesz/patch-1
[docs] Make sure to note "Install OR update"
2015-10-05 16:01:58 -07:00
fresheneesz
49f2c95013 Install OR update 2015-10-05 15:56:41 -07:00
Jordan Harband
06a21284ed Protect against cat clobbering. Fixes #858. 2015-10-04 14:28:38 -07:00
7 changed files with 120 additions and 44 deletions

View File

@@ -13,13 +13,13 @@ Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creati
### Install script ### Install script
To install you could use the [install script][2] using cURL: To install or update nvm, you can use the [install script][2] using cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.28.0/install.sh | bash curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
or Wget: or Wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.28.0/install.sh | bash wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub> <sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
@@ -236,7 +236,7 @@ After the v0.8.6 release of node, nvm tries to install from binary packages. But
nvm install -s 0.8.6 nvm install -s 0.8.6
[1]: https://github.com/creationix/nvm.git [1]: https://github.com/creationix/nvm.git
[2]: https://github.com/creationix/nvm/blob/v0.28.0/install.sh [2]: https://github.com/creationix/nvm/blob/v0.29.0/install.sh
[3]: https://travis-ci.org/creationix/nvm [3]: https://travis-ci.org/creationix/nvm
[Urchin]: https://github.com/scraperwiki/urchin [Urchin]: https://github.com/scraperwiki/urchin
[Fish]: http://fishshell.com [Fish]: http://fishshell.com

View File

@@ -11,7 +11,7 @@ if [ -z "$NVM_DIR" ]; then
fi fi
nvm_latest_version() { nvm_latest_version() {
echo "v0.28.0" echo "v0.29.0"
} }
# #

110
nvm.sh
View File

@@ -78,7 +78,7 @@ if [ -z "$NVM_DIR" ]; then
if [ -n "$BASH_SOURCE" ]; then if [ -n "$BASH_SOURCE" ]; then
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}" NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
fi fi
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname "${NVM_SCRIPT_SOURCE:-$0}") > /dev/null && \pwd) export NVM_DIR="$(cd $NVM_CD_FLAGS $(dirname "${NVM_SCRIPT_SOURCE:-$0}") > /dev/null && \pwd)"
fi fi
unset NVM_SCRIPT_SOURCE 2> /dev/null unset NVM_SCRIPT_SOURCE 2> /dev/null
@@ -221,7 +221,7 @@ nvm_ensure_version_installed() {
# Expand a version using the version cache # Expand a version using the version cache
nvm_version() { nvm_version() {
local PATTERN local PATTERN
PATTERN=$1 PATTERN="$1"
local VERSION local VERSION
# The default version is the current one # The default version is the current one
if [ -z "$PATTERN" ]; then if [ -z "$PATTERN" ]; then
@@ -398,7 +398,7 @@ nvm_alias() {
return 2 return 2
fi fi
cat "$NVM_ALIAS_PATH" command cat "$NVM_ALIAS_PATH"
} }
nvm_ls_current() { nvm_ls_current() {
@@ -592,39 +592,51 @@ nvm_ls() {
setopt shwordsplit setopt shwordsplit
fi fi
local NVM_DIRS_TO_TEST_AND_SEARCH local NVM_DIRS_TO_SEARCH1
local NVM_DIRS_TO_SEARCH NVM_DIRS_TO_SEARCH1=''
local NVM_DIRS_TO_SEARCH2
NVM_DIRS_TO_SEARCH2=''
local NVM_DIRS_TO_SEARCH3
NVM_DIRS_TO_SEARCH3=''
local NVM_ADD_SYSTEM local NVM_ADD_SYSTEM
NVM_ADD_SYSTEM=false NVM_ADD_SYSTEM=false
if nvm_is_iojs_version "$PATTERN"; then if nvm_is_iojs_version "$PATTERN"; then
NVM_DIRS_TO_TEST_AND_SEARCH="$NVM_VERSION_DIR_IOJS" NVM_DIRS_TO_SEARCH1="$NVM_VERSION_DIR_IOJS"
PATTERN="$(nvm_strip_iojs_prefix "$PATTERN")" PATTERN="$(nvm_strip_iojs_prefix "$PATTERN")"
if nvm_has_system_iojs; then if nvm_has_system_iojs; then
NVM_ADD_SYSTEM=true NVM_ADD_SYSTEM=true
fi fi
elif [ "_$PATTERN" = "_$NVM_NODE_PREFIX-" ]; then elif [ "_$PATTERN" = "_$NVM_NODE_PREFIX-" ]; then
NVM_DIRS_TO_TEST_AND_SEARCH="$NVM_VERSION_DIR_OLD $NVM_VERSION_DIR_NEW" NVM_DIRS_TO_SEARCH1="$NVM_VERSION_DIR_OLD"
NVM_DIRS_TO_SEARCH2="$NVM_VERSION_DIR_NEW"
PATTERN='' PATTERN=''
if nvm_has_system_node; then if nvm_has_system_node; then
NVM_ADD_SYSTEM=true NVM_ADD_SYSTEM=true
fi fi
else else
NVM_DIRS_TO_TEST_AND_SEARCH="$NVM_VERSION_DIR_OLD $NVM_VERSION_DIR_NEW $NVM_VERSION_DIR_IOJS" NVM_DIRS_TO_SEARCH1="$NVM_VERSION_DIR_OLD"
NVM_DIRS_TO_SEARCH2="$NVM_VERSION_DIR_NEW"
NVM_DIRS_TO_SEARCH3="$NVM_VERSION_DIR_IOJS"
if nvm_has_system_iojs || nvm_has_system_node; then if nvm_has_system_iojs || nvm_has_system_node; then
NVM_ADD_SYSTEM=true NVM_ADD_SYSTEM=true
fi fi
fi fi
for NVM_VERSION_DIR in $NVM_DIRS_TO_TEST_AND_SEARCH; do
if [ -d "$NVM_VERSION_DIR" ]; then if ! [ -d "$NVM_DIRS_TO_SEARCH1" ]; then
NVM_DIRS_TO_SEARCH="$NVM_VERSION_DIR $NVM_DIRS_TO_SEARCH" NVM_DIRS_TO_SEARCH1=''
fi fi
done if ! [ -d "$NVM_DIRS_TO_SEARCH2" ]; then
NVM_DIRS_TO_SEARCH2="$NVM_DIRS_TO_SEARCH1"
fi
if ! [ -d "$NVM_DIRS_TO_SEARCH3" ]; then
NVM_DIRS_TO_SEARCH3="$NVM_DIRS_TO_SEARCH2"
fi
if [ -z "$PATTERN" ]; then if [ -z "$PATTERN" ]; then
PATTERN='v' PATTERN='v'
fi fi
if [ -n "$NVM_DIRS_TO_SEARCH" ]; then if [ -n "$NVM_DIRS_TO_SEARCH1$NVM_DIRS_TO_SEARCH2$NVM_DIRS_TO_SEARCH3" ]; then
VERSIONS="$(command find $NVM_DIRS_TO_SEARCH -maxdepth 1 -type d -name "$PATTERN*" \ VERSIONS="$(command find "$NVM_DIRS_TO_SEARCH1" "$NVM_DIRS_TO_SEARCH2" "$NVM_DIRS_TO_SEARCH3" -maxdepth 1 -type d -name "$PATTERN*" \
| command sed " | command sed "
s#$NVM_VERSION_DIR_IOJS/#$NVM_IOJS_PREFIX-#; s#$NVM_VERSION_DIR_IOJS/#$NVM_IOJS_PREFIX-#;
\#$NVM_VERSION_DIR_IOJS# d; \#$NVM_VERSION_DIR_IOJS# d;
@@ -987,18 +999,27 @@ nvm_install_merged_node_binary() {
local url local url
local sum local sum
local NODE_PREFIX local NODE_PREFIX
local compression
compression="gz"
local tar_compression_flag
tar_compression_flag="x"
if nvm_supports_xz "$VERSION"; then
compression="xz"
tar_compression_flag="J"
fi
NODE_PREFIX="$(nvm_node_prefix)" NODE_PREFIX="$(nvm_node_prefix)"
if [ -n "$NVM_OS" ]; then if [ -n "$NVM_OS" ]; then
t="$VERSION-$NVM_OS-$(nvm_get_arch)" t="$VERSION-$NVM_OS-$(nvm_get_arch)"
url="$MIRROR/$VERSION/$NODE_PREFIX-${t}.tar.gz" url="$MIRROR/$VERSION/$NODE_PREFIX-${t}.tar.${compression}"
sum="$(nvm_download -L -s $MIRROR/$VERSION/SHASUMS256.txt -o - | command grep $NODE_PREFIX-${t}.tar.gz | command awk '{print $1}')" sum="$(nvm_download -L -s $MIRROR/$VERSION/SHASUMS256.txt -o - | command grep $NODE_PREFIX-${t}.tar.${compression} | command awk '{print $1}')"
local tmpdir local tmpdir
tmpdir="$NVM_DIR/bin/node-${t}" tmpdir="$NVM_DIR/bin/node-${t}"
local tmptarball local tmptarball
tmptarball="$tmpdir/node-${t}.tar.gz" tmptarball="$tmpdir/node-${t}.tar.${compression}"
local NVM_INSTALL_ERRORED local NVM_INSTALL_ERRORED
command mkdir -p "$tmpdir" && \ command mkdir -p "$tmpdir" && \
echo "Downloading $url..." && \
nvm_download -L -C - --progress-bar $url -o "$tmptarball" || \ nvm_download -L -C - --progress-bar $url -o "$tmptarball" || \
NVM_INSTALL_ERRORED=true NVM_INSTALL_ERRORED=true
if grep '404 Not Found' "$tmptarball" >/dev/null; then if grep '404 Not Found' "$tmptarball" >/dev/null; then
@@ -1009,7 +1030,7 @@ nvm_install_merged_node_binary() {
[ "$NVM_INSTALL_ERRORED" != true ] && \ [ "$NVM_INSTALL_ERRORED" != true ] && \
echo "WARNING: checksums are currently disabled for node.js v4.0 and later" >&2 && \ echo "WARNING: checksums are currently disabled for node.js v4.0 and later" >&2 && \
# nvm_checksum "$tmptarball" $sum && \ # nvm_checksum "$tmptarball" $sum && \
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \ command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
command rm -f "$tmptarball" && \ command rm -f "$tmptarball" && \
command mkdir -p "$VERSION_PATH" && \ command mkdir -p "$VERSION_PATH" && \
command mv "$tmpdir"/* "$VERSION_PATH" command mv "$tmpdir"/* "$VERSION_PATH"
@@ -1053,18 +1074,27 @@ nvm_install_iojs_binary() {
local t local t
local url local url
local sum local sum
local compression
compression="gz"
local tar_compression_flag
tar_compression_flag="x"
if nvm_supports_xz "$VERSION"; then
compression="xz"
tar_compression_flag="J"
fi
if [ -n "$NVM_OS" ]; then if [ -n "$NVM_OS" ]; then
if nvm_binary_available "$VERSION"; then if nvm_binary_available "$VERSION"; then
t="$VERSION-$NVM_OS-$(nvm_get_arch)" t="$VERSION-$NVM_OS-$(nvm_get_arch)"
url="$MIRROR/$VERSION/$(nvm_iojs_prefix)-${t}.tar.gz" url="$MIRROR/$VERSION/$(nvm_iojs_prefix)-${t}.tar.${compression}"
sum="$(nvm_download -L -s $MIRROR/$VERSION/SHASUMS256.txt -o - | command grep $(nvm_iojs_prefix)-${t}.tar.gz | command awk '{print $1}')" sum="$(nvm_download -L -s $MIRROR/$VERSION/SHASUMS256.txt -o - | command grep $(nvm_iojs_prefix)-${t}.tar.${compression} | command awk '{print $1}')"
local tmpdir local tmpdir
tmpdir="$NVM_DIR/bin/iojs-${t}" tmpdir="$NVM_DIR/bin/iojs-${t}"
local tmptarball local tmptarball
tmptarball="$tmpdir/iojs-${t}.tar.gz" tmptarball="$tmpdir/iojs-${t}.tar.${compression}"
local NVM_INSTALL_ERRORED local NVM_INSTALL_ERRORED
command mkdir -p "$tmpdir" && \ command mkdir -p "$tmpdir" && \
echo "Downloading $url..." && \
nvm_download -L -C - --progress-bar $url -o "$tmptarball" || \ nvm_download -L -C - --progress-bar $url -o "$tmptarball" || \
NVM_INSTALL_ERRORED=true NVM_INSTALL_ERRORED=true
if grep '404 Not Found' "$tmptarball" >/dev/null; then if grep '404 Not Found' "$tmptarball" >/dev/null; then
@@ -1075,7 +1105,7 @@ nvm_install_iojs_binary() {
[ "$NVM_INSTALL_ERRORED" != true ] && \ [ "$NVM_INSTALL_ERRORED" != true ] && \
echo "WARNING: checksums are currently disabled for io.js" >&2 && \ echo "WARNING: checksums are currently disabled for io.js" >&2 && \
# nvm_checksum "$tmptarball" $sum && \ # nvm_checksum "$tmptarball" $sum && \
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \ command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
command rm -f "$tmptarball" && \ command rm -f "$tmptarball" && \
command mkdir -p "$VERSION_PATH" && \ command mkdir -p "$VERSION_PATH" && \
command mv "$tmpdir"/* "$VERSION_PATH" command mv "$tmpdir"/* "$VERSION_PATH"
@@ -1197,6 +1227,7 @@ nvm_install_node_source() {
if ( if (
[ -n "$tarball" ] && \ [ -n "$tarball" ] && \
command mkdir -p "$tmpdir" && \ command mkdir -p "$tmpdir" && \
echo "Downloading $tarball..." && \
nvm_download -L --progress-bar $tarball -o "$tmptarball" && \ nvm_download -L --progress-bar $tarball -o "$tmptarball" && \
nvm_checksum "$tmptarball" $sum && \ nvm_checksum "$tmptarball" $sum && \
command tar -xzf "$tmptarball" -C "$tmpdir" && \ command tar -xzf "$tmptarball" -C "$tmpdir" && \
@@ -1371,9 +1402,9 @@ nvm_sanitize_path() {
local SANITIZED_PATH local SANITIZED_PATH
SANITIZED_PATH="$1" SANITIZED_PATH="$1"
if [ "_$1" != "_$NVM_DIR" ]; then if [ "_$1" != "_$NVM_DIR" ]; then
SANITIZED_PATH="$(echo "$SANITIZED_PATH" | sed "s#$NVM_DIR#\$NVM_DIR#g")" SANITIZED_PATH="$(echo "$SANITIZED_PATH" | command sed "s#$NVM_DIR#\$NVM_DIR#g")"
fi fi
echo "$SANITIZED_PATH" | sed "s#$HOME#\$HOME#g" echo "$SANITIZED_PATH" | command sed "s#$HOME#\$HOME#g"
} }
nvm() { nvm() {
@@ -1647,9 +1678,9 @@ nvm() {
fi fi
# Delete all files related to target version. # Delete all files related to target version.
command rm -rf "$NVM_DIR/src/$NVM_PREFIX-$VERSION" \ command rm -rf "$NVM_DIR/src/$NVM_PREFIX-$VERSION" \
"$NVM_DIR/src/$NVM_PREFIX-$VERSION.tar.gz" \ "$NVM_DIR/src/$NVM_PREFIX-$VERSION.tar.*" \
"$NVM_DIR/bin/$NVM_PREFIX-${t}" \ "$NVM_DIR/bin/$NVM_PREFIX-${t}" \
"$NVM_DIR/bin/$NVM_PREFIX-${t}.tar.gz" \ "$NVM_DIR/bin/$NVM_PREFIX-${t}.tar.*" \
"$VERSION_PATH" 2>/dev/null "$VERSION_PATH" 2>/dev/null
echo "$NVM_SUCCESS_MSG" echo "$NVM_SUCCESS_MSG"
@@ -1777,13 +1808,14 @@ nvm() {
if [ "$NVM_SYMLINK_CURRENT" = true ]; then if [ "$NVM_SYMLINK_CURRENT" = true ]; then
command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current" command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
fi fi
local NVM_USE_OUTPUT
if nvm_is_iojs_version "$VERSION"; then if nvm_is_iojs_version "$VERSION"; then
if [ $NVM_USE_SILENT -ne 1 ]; then if [ $NVM_USE_SILENT -ne 1 ]; then
echo "Now using io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)" NVM_USE_OUTPUT="Now using io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)"
fi fi
else else
if [ $NVM_USE_SILENT -ne 1 ]; then if [ $NVM_USE_SILENT -ne 1 ]; then
echo "Now using node $VERSION$(nvm_print_npm_version)" NVM_USE_OUTPUT="Now using node $VERSION$(nvm_print_npm_version)"
fi fi
fi fi
if [ "_$VERSION" != "_system" ]; then if [ "_$VERSION" != "_system" ]; then
@@ -1799,6 +1831,9 @@ nvm() {
return 11 return 11
fi fi
fi fi
if [ -n "$NVM_USE_OUTPUT" ]; then
echo "$NVM_USE_OUTPUT"
fi
;; ;;
"run" ) "run" )
local provided_version local provided_version
@@ -1827,7 +1862,7 @@ nvm() {
fi fi
fi fi
provided_version=$1 provided_version="$1"
if [ -n "$provided_version" ]; then if [ -n "$provided_version" ]; then
VERSION="$(nvm_version "$provided_version")" VERSION="$(nvm_version "$provided_version")"
if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then
@@ -1858,8 +1893,8 @@ nvm() {
setopt shwordsplit setopt shwordsplit
fi fi
if [ "_$VERSION" = "_N/A" ]; then if [ "_$VERSION" = "_N/A" ]; then
echo "$(nvm_ensure_version_prefix "$provided_version") is not installed yet" >&2 nvm_ensure_version_installed "$provided_version"
EXIT_CODE=1 EXIT_CODE=$?
elif [ -z "$ARGS" ]; then elif [ -z "$ARGS" ]; then
if [ "$NVM_IOJS" = true ]; then if [ "$NVM_IOJS" = true ]; then
nvm exec "$VERSION" iojs nvm exec "$VERSION" iojs
@@ -1898,7 +1933,7 @@ nvm() {
provided_version="$1" provided_version="$1"
if [ -n "$provided_version" ]; then if [ -n "$provided_version" ]; then
VERSION="$(nvm_version "$provided_version")" VERSION="$(nvm_version "$provided_version")"
if [ "_$VERSION" = "_N/A" ]; then if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then
nvm_rc_version nvm_rc_version
provided_version="$NVM_RC_VERSION" provided_version="$NVM_RC_VERSION"
VERSION="$(nvm_version "$provided_version")" VERSION="$(nvm_version "$provided_version")"
@@ -2149,7 +2184,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
nvm_remote_version "$2" nvm_remote_version "$2"
;; ;;
"--version" ) "--version" )
echo "0.28.0" echo "0.29.0"
;; ;;
"unload" ) "unload" )
unset -f nvm nvm_print_versions nvm_checksum \ unset -f nvm nvm_print_versions nvm_checksum \
@@ -2174,7 +2209,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
nvm_print_npm_version nvm_npm_global_modules \ nvm_print_npm_version nvm_npm_global_modules \
nvm_has_system_node nvm_has_system_iojs \ nvm_has_system_node nvm_has_system_iojs \
nvm_download nvm_get_latest nvm_has nvm_get_latest \ nvm_download nvm_get_latest nvm_has nvm_get_latest \
nvm_supports_source_options > /dev/null 2>&1 nvm_supports_source_options nvm_supports_xz > /dev/null 2>&1
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1 unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
;; ;;
* ) * )
@@ -2188,6 +2223,11 @@ nvm_supports_source_options() {
[ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ] [ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ]
} }
nvm_supports_xz() {
command which xz 2>&1 >/dev/null && \
nvm_version_greater_than_or_equal_to "$1" "2.3.2"
}
NVM_VERSION="$(nvm_alias default 2>/dev/null || echo)" NVM_VERSION="$(nvm_alias default 2>/dev/null || echo)"
if nvm_supports_source_options && [ "_$1" = "_--install" ]; then if nvm_supports_source_options && [ "_$1" = "_--install" ]; then
if [ -n "$NVM_VERSION" ]; then if [ -n "$NVM_VERSION" ]; then

View File

@@ -1,6 +1,6 @@
{ {
"name": "nvm", "name": "nvm",
"version": "0.28.0", "version": "0.29.0",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions", "description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": { "directories": {
"test": "test" "test": "test"

View File

@@ -0,0 +1,36 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
OLDPATH=$PATH
TEST_PATH=../../xz-test
mkdir $TEST_PATH
touch ../../xz-test/xz
chmod +x ../../xz-test/xz
export PATH=$TEST_PATH:$PATH
$(nvm_supports_xz "v2.3.2") || \
die "expected 'nvm_supports_xz v2.3.2' to exit with 0"
$(nvm_supports_xz "v0.12.7") && \
die "expected 'nvm_supports_xz v0.12.7' to exit with 1"
# set up for a failure by having a minimal toolset available
# but remove xz
ln -s /usr/bin/which $TEST_PATH/which
ln -s /usr/bin/command $TEST_PATH/command
ln -s /usr/bin/awk $TEST_PATH/awk
ln -s $(which rm) $TEST_PATH/rm
export PATH=$TEST_PATH
rm $TEST_PATH/xz
$(nvm_supports_xz "v2.3.2") && \
die "expected 'nvm_supports_xz v2.3.2' with a missing xz binary to exit with 1"
export PATH=$OLDPATH

View File

@@ -6,5 +6,5 @@
type setopt >/dev/null 2>&1 && setopt NULL_GLOB type setopt >/dev/null 2>&1 && setopt NULL_GLOB
type shopt >/dev/null 2>&1 && shopt -s nullglob type shopt >/dev/null 2>&1 && shopt -s nullglob
rm -fR v* src alias rm -fR v* src alias test/test-xz
) )

View File

@@ -5,5 +5,5 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh . ../../../nvm.sh
[ "$(nvm run 0.2 --version 2>&1)" = "v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly" [ "$(nvm run 0.2 --version 2>&1)" = 'N/A: version "v0.2" is not yet installed' ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly"
[ "$(nvm run iojs-0.2 --version 2>&1)" = "iojs-v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly" [ "$(nvm run iojs-0.2 --version 2>&1)" = 'N/A: version "iojs-v0.2" is not yet installed' ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"