merge with master
commit
7805492bda
|
@ -12,11 +12,11 @@ Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/n
|
||||||
|
|
||||||
To install you could use the [install script][2] using cURL:
|
To install you could use the [install script][2] using cURL:
|
||||||
|
|
||||||
curl https://raw.githubusercontent.com/creationix/nvm/v0.18.0/install.sh | bash
|
curl https://raw.githubusercontent.com/creationix/nvm/v0.20.0/install.sh | bash
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.18.0/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.20.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>
|
||||||
|
|
||||||
|
@ -150,8 +150,9 @@ Put the above sourcing line just below the sourcing line for NVM in your profile
|
||||||
nvm
|
nvm
|
||||||
|
|
||||||
$ nvm [tab][tab]
|
$ nvm [tab][tab]
|
||||||
alias copy-packages help list run uninstall version
|
alias deactivate install ls run unload
|
||||||
clear-cache deactivate install ls unalias use
|
clear-cache exec list ls-remote unalias use
|
||||||
|
current help list-remote reinstall-packages uninstall version
|
||||||
|
|
||||||
nvm alias
|
nvm alias
|
||||||
|
|
||||||
|
@ -190,7 +191,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.18.0/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.20.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
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@ __nvm_commands ()
|
||||||
current_word="${COMP_WORDS[COMP_CWORD]}"
|
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
|
||||||
COMMANDS='\
|
COMMANDS='\
|
||||||
help install uninstall use run exec\
|
help install uninstall use run exec \
|
||||||
alias unalias copy-packages
|
alias unalias reinstall-packages \
|
||||||
current list ls list-remote ls-remote\
|
current list ls list-remote ls-remote \
|
||||||
clear-cache deactivate unload
|
clear-cache deactivate unload \
|
||||||
version'
|
version'
|
||||||
|
|
||||||
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
||||||
|
|
20
install.sh
20
install.sh
|
@ -27,7 +27,9 @@ nvm_source() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ "_$NVM_METHOD" = "_script" ]; then
|
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.18.0/nvm.sh"
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.20.0/nvm.sh"
|
||||||
|
elif [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||||
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.20.0/nvm-exec"
|
||||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||||
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||||
else
|
else
|
||||||
|
@ -67,13 +69,15 @@ install_nvm_from_git() {
|
||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
git clone "$(nvm_source "git")" "$NVM_DIR"
|
git clone "$(nvm_source "git")" "$NVM_DIR"
|
||||||
fi
|
fi
|
||||||
cd "$NVM_DIR" && git checkout v0.18.0 && git branch -D master >/dev/null 2>&1
|
cd "$NVM_DIR" && git checkout v0.20.0 && git branch -D master >/dev/null 2>&1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
install_nvm_as_script() {
|
install_nvm_as_script() {
|
||||||
local NVM_SOURCE
|
local NVM_SOURCE
|
||||||
NVM_SOURCE=$(nvm_source "script")
|
NVM_SOURCE=$(nvm_source "script")
|
||||||
|
local NVM_EXEC_SOURCE
|
||||||
|
NVM_EXEC_SOURCE=$(nvm_source "script-nvm-exec")
|
||||||
|
|
||||||
# Downloading to $NVM_DIR
|
# Downloading to $NVM_DIR
|
||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
|
@ -82,10 +86,18 @@ install_nvm_as_script() {
|
||||||
else
|
else
|
||||||
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||||
fi
|
fi
|
||||||
nvm_download -s "$_source" -o "$NVM_DIR/nvm.sh" || {
|
nvm_download -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
|
||||||
echo >&2 "Failed to download '$_source'.."
|
echo >&2 "Failed to download '$NVM_SOURCE'"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
nvm_download -s "$NVM_EXEC_SOURCE" -o "$NVM_DIR/nvm-exec" || {
|
||||||
|
echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
chmod a+x "$NVM_DIR/nvm-exec" || {
|
||||||
|
echo >&2 "Failed to mark '$NVM_DIR/nvm-exec' as executable"
|
||||||
|
return 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
67
nvm.sh
67
nvm.sh
|
@ -253,11 +253,11 @@ nvm_alias() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_ls_current() {
|
nvm_ls_current() {
|
||||||
local NODE_PATH
|
local NVM_LS_CURRENT_NODE_PATH
|
||||||
NODE_PATH="$(which node 2> /dev/null)"
|
NVM_LS_CURRENT_NODE_PATH="$(which node 2> /dev/null)"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo 'none'
|
echo 'none'
|
||||||
elif nvm_tree_contains_path "$NVM_DIR" "$NODE_PATH"; then
|
elif nvm_tree_contains_path "$NVM_DIR" "$NVM_LS_CURRENT_NODE_PATH"; then
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION=`node -v 2>/dev/null`
|
VERSION=`node -v 2>/dev/null`
|
||||||
if [ "$VERSION" = "v0.6.21-pre" ]; then
|
if [ "$VERSION" = "v0.6.21-pre" ]; then
|
||||||
|
@ -541,19 +541,20 @@ nvm() {
|
||||||
echo " nvm ls List installed versions"
|
echo " nvm ls List installed versions"
|
||||||
echo " nvm ls <version> List versions matching a given description"
|
echo " nvm ls <version> List versions matching a given description"
|
||||||
echo " nvm ls-remote List remote versions available for install"
|
echo " nvm ls-remote List remote versions available for install"
|
||||||
echo " nvm deactivate Undo effects of NVM on current shell"
|
echo " nvm deactivate Undo effects of \`nvm\` on current shell"
|
||||||
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
|
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
|
||||||
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
||||||
echo " nvm unalias <name> Deletes the alias named <name>"
|
echo " nvm unalias <name> Deletes the alias named <name>"
|
||||||
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
|
echo " nvm reinstall-packages <version> Reinstall global \`npm\` packages contained in <version> to current version"
|
||||||
echo " nvm unload Unload NVM from shell"
|
echo " nvm unload Unload \`nvm\` from shell"
|
||||||
echo " nvm which [<version>] Display path to installed node version"
|
echo " nvm which [<version>] Display path to installed node version"
|
||||||
echo
|
echo
|
||||||
echo "Example:"
|
echo "Example:"
|
||||||
echo " nvm install v0.10.24 Install a specific version number"
|
echo " nvm install v0.10.32 Install a specific version number"
|
||||||
echo " nvm use 0.10 Use the latest available 0.10.x release"
|
echo " nvm use 0.10 Use the latest available 0.10.x release"
|
||||||
echo " nvm run 0.10.24 myApp.js Run myApp.js using node v0.10.24"
|
echo " nvm run 0.10.32 app.js Run app.js using node v0.10.32"
|
||||||
echo " nvm alias default 0.10.24 Set default node version on a shell"
|
echo " nvm exec 0.10.32 node app.js Run \`node app.js\` with the PATH pointing to node v0.10.32"
|
||||||
|
echo " nvm alias default 0.10.32 Set default node version on a shell"
|
||||||
echo
|
echo
|
||||||
echo "Note:"
|
echo "Note:"
|
||||||
echo " to remove, delete, or uninstall nvm - just remove ~/.nvm, ~/.npm, and ~/.bower folders"
|
echo " to remove, delete, or uninstall nvm - just remove ~/.nvm, ~/.npm, and ~/.bower folders"
|
||||||
|
@ -611,32 +612,35 @@ nvm() {
|
||||||
|
|
||||||
VERSION="$(nvm_remote_version "$provided_version")"
|
VERSION="$(nvm_remote_version "$provided_version")"
|
||||||
ADDITIONAL_PARAMETERS=''
|
ADDITIONAL_PARAMETERS=''
|
||||||
local PROVIDED_COPY_PACKAGES_FROM
|
local PROVIDED_REINSTALL_PACKAGES_FROM
|
||||||
local COPY_PACKAGES_FROM
|
local REINSTALL_PACKAGES_FROM
|
||||||
|
|
||||||
while [ $# -ne 0 ]
|
while [ $# -ne 0 ]
|
||||||
do
|
do
|
||||||
if [ "_$(echo "$1" | cut -c 1-21)" = "_--copy-packages-from=" ]; then
|
if [ "_$(echo "$1" | cut -c 1-26)" = "_--reinstall-packages-from=" ]; then
|
||||||
PROVIDED_COPY_PACKAGES_FROM="$(echo "$1" | cut -c 22-)"
|
PROVIDED_REINSTALL_PACKAGES_FROM="$(echo "$1" | cut -c 27-)"
|
||||||
COPY_PACKAGES_FROM="$(nvm_version "$PROVIDED_COPY_PACKAGES_FROM")"
|
REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")"
|
||||||
|
elif [ "_$(echo "$1" | cut -c 1-21)" = "_--copy-packages-from=" ]; then
|
||||||
|
PROVIDED_REINSTALL_PACKAGES_FROM="$(echo "$1" | cut -c 22-)"
|
||||||
|
REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")"
|
||||||
else
|
else
|
||||||
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
|
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "_$(nvm_ensure_version_prefix "$PROVIDED_COPY_PACKAGES_FROM")" = "_$VERSION" ]; then
|
if [ "_$(nvm_ensure_version_prefix "$PROVIDED_REINSTALL_PACKAGES_FROM")" = "_$VERSION" ]; then
|
||||||
echo "You can't copy global packages from the same version of node you're installing." >&2
|
echo "You can't reinstall global packages from the same version of node you're installing." >&2
|
||||||
return 4
|
return 4
|
||||||
elif [ ! -z "$PROVIDED_COPY_PACKAGES_FROM" ] && [ "_$COPY_PACKAGES_FROM" = "_N/A" ]; then
|
elif [ ! -z "$PROVIDED_REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" = "_N/A" ]; then
|
||||||
echo "If --copy-packages-from is provided, it must point to an installed version of node." >&2
|
echo "If --reinstall-packages-from is provided, it must point to an installed version of node." >&2
|
||||||
return 5
|
return 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$(nvm_version_path "$VERSION")" ]; then
|
if [ -d "$(nvm_version_path "$VERSION")" ]; then
|
||||||
echo "$VERSION is already installed." >&2
|
echo "$VERSION is already installed." >&2
|
||||||
if nvm use "$VERSION" && [ ! -z "$COPY_PACKAGES_FROM" ] && [ "_$COPY_PACKAGES_FROM" != "_N/A" ]; then
|
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||||
nvm copy-packages "$COPY_PACKAGES_FROM"
|
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||||
fi
|
fi
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
@ -667,8 +671,8 @@ nvm() {
|
||||||
mv "$tmpdir" "$(nvm_version_path "$VERSION")"
|
mv "$tmpdir" "$(nvm_version_path "$VERSION")"
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
if nvm use "$VERSION" && [ ! -z "$COPY_PACKAGES_FROM" ] && [ "_$COPY_PACKAGES_FROM" != "_N/A" ]; then
|
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||||
nvm copy-packages "$COPY_PACKAGES_FROM"
|
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||||
fi
|
fi
|
||||||
return $?
|
return $?
|
||||||
else
|
else
|
||||||
|
@ -713,8 +717,8 @@ nvm() {
|
||||||
$make $MAKE_CXX install
|
$make $MAKE_CXX install
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
if nvm use "$VERSION" && [ ! -z "$COPY_PACKAGES_FROM" ] && [ "_$COPY_PACKAGES_FROM" != "_N/A" ]; then
|
if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
|
||||||
nvm copy-packages "$COPY_PACKAGES_FROM"
|
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
|
||||||
fi
|
fi
|
||||||
if ! nvm_has "npm" ; then
|
if ! nvm_has "npm" ; then
|
||||||
echo "Installing npm..."
|
echo "Installing npm..."
|
||||||
|
@ -787,9 +791,7 @@ nvm() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NEWPATH="$(nvm_strip_path "$NODE_PATH" "/lib/node_modules")"
|
NEWPATH="$(nvm_strip_path "$NODE_PATH" "/lib/node_modules")"
|
||||||
if [ "$NODE_PATH" = "$NEWPATH" ]; then
|
if [ "$NODE_PATH" != "$NEWPATH" ]; then
|
||||||
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH" >&2
|
|
||||||
else
|
|
||||||
export NODE_PATH="$NEWPATH"
|
export NODE_PATH="$NEWPATH"
|
||||||
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
|
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
|
||||||
fi
|
fi
|
||||||
|
@ -847,13 +849,8 @@ nvm() {
|
||||||
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man"`
|
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man"`
|
||||||
export MANPATH
|
export MANPATH
|
||||||
fi
|
fi
|
||||||
# Strip other version from NODE_PATH
|
|
||||||
NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
|
||||||
# Prepend current version
|
|
||||||
NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"`
|
|
||||||
export PATH
|
export PATH
|
||||||
hash -r
|
hash -r
|
||||||
export NODE_PATH
|
|
||||||
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
|
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
|
||||||
export NVM_BIN="$NVM_VERSION_DIR/bin"
|
export NVM_BIN="$NVM_VERSION_DIR/bin"
|
||||||
if [ "$NVM_SYMLINK_CURRENT" = true ]; then
|
if [ "$NVM_SYMLINK_CURRENT" = true ]; then
|
||||||
|
@ -1040,7 +1037,7 @@ nvm() {
|
||||||
rm -f $NVM_DIR/alias/$2
|
rm -f $NVM_DIR/alias/$2
|
||||||
echo "Deleted alias $2"
|
echo "Deleted alias $2"
|
||||||
;;
|
;;
|
||||||
"copy-packages" )
|
"reinstall-packages" | "copy-packages" )
|
||||||
if [ $# -ne 2 ]; then
|
if [ $# -ne 2 ]; then
|
||||||
nvm help
|
nvm help
|
||||||
return 127
|
return 127
|
||||||
|
@ -1050,7 +1047,7 @@ nvm() {
|
||||||
PROVIDED_VERSION="$2"
|
PROVIDED_VERSION="$2"
|
||||||
|
|
||||||
if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ] || [ "$(nvm_version $PROVIDED_VERSION)" = "$(nvm_ls_current)" ]; then
|
if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ] || [ "$(nvm_version $PROVIDED_VERSION)" = "$(nvm_ls_current)" ]; then
|
||||||
echo 'Can not copy packages from the current version of node.' >&2
|
echo 'Can not reinstall packages from the current version of node.' >&2
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1078,7 +1075,7 @@ nvm() {
|
||||||
nvm_version $2
|
nvm_version $2
|
||||||
;;
|
;;
|
||||||
"--version" )
|
"--version" )
|
||||||
echo "0.18.0"
|
echo "0.20.0"
|
||||||
;;
|
;;
|
||||||
"unload" )
|
"unload" )
|
||||||
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater nvm_version_greater_than_or_equal_to > /dev/null 2>&1
|
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater nvm_version_greater_than_or_equal_to > /dev/null 2>&1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.18.0",
|
"version": "0.20.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"
|
||||||
|
|
|
@ -8,7 +8,8 @@ die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
nvm use v0.2.3 &&
|
nvm use v0.2.3 &&
|
||||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3"
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to activate v0.2.3"
|
||||||
|
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
|
||||||
|
|
||||||
nvm deactivate &&
|
nvm deactivate &&
|
||||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3"
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3"
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
die () { echo $@ ; cleanup ; exit 1; }
|
|
||||||
cleanup () {
|
|
||||||
rm -rf ../../v0.10.4
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir ../../v0.10.4
|
|
||||||
|
|
||||||
. ../../nvm.sh
|
|
||||||
|
|
||||||
nvm deactivate >/dev/null 2>&1
|
|
||||||
|
|
||||||
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --copy-packages-from=0.11 2>&1)"
|
|
||||||
EXPECTED_ERROR_MSG="If --copy-packages-from is provided, it must point to an installed version of node."
|
|
||||||
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|
|
||||||
|| die ""nvm install --copy-packages" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
|
|
||||||
|
|
||||||
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --copy-packages-from=0.11 >/dev/null 2>&1; echo $?)"
|
|
||||||
[ "~$INSTALL_EXIT_CODE" = "~5" ] \
|
|
||||||
|| die ""nvm install --copy-packages" should exit with code 5 when given an uninstalled version, got $INSTALL_EXIT_CODE"
|
|
||||||
|
|
||||||
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --copy-packages-from=0.10.5 2>&1)"
|
|
||||||
EXPECTED_ERROR_MSG="You can't copy global packages from the same version of node you're installing."
|
|
||||||
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|
|
||||||
|| die ""nvm install --copy-packages" should fail when given the same version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
|
|
||||||
|
|
||||||
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --copy-packages-from=0.10.5 >/dev/null 2>&1; echo $?)"
|
|
||||||
[ "~$INSTALL_EXIT_CODE" = "~4" ] \
|
|
||||||
|| die ""nvm install --copy-packages" should exit with code 4 when given the same version, got $INSTALL_EXIT_CODE"
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
cleanup () {
|
||||||
|
rm -rf ../../v0.10.4
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir ../../v0.10.4
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
nvm deactivate >/dev/null 2>&1
|
||||||
|
|
||||||
|
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from=0.11 2>&1)"
|
||||||
|
EXPECTED_ERROR_MSG="If --reinstall-packages-from is provided, it must point to an installed version of node."
|
||||||
|
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|
||||||
|
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
|
||||||
|
|
||||||
|
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --reinstall-packages-from=0.11 >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "~$INSTALL_EXIT_CODE" = "~5" ] \
|
||||||
|
|| die ""nvm install --reinstall-packages-from" should exit with code 5 when given an uninstalled version, got $INSTALL_EXIT_CODE"
|
||||||
|
|
||||||
|
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from=0.10.5 2>&1)"
|
||||||
|
EXPECTED_ERROR_MSG="You can't reinstall global packages from the same version of node you're installing."
|
||||||
|
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|
||||||
|
|| die ""nvm install --reinstall-packages-from" should fail when given the same version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
|
||||||
|
|
||||||
|
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --reinstall-packages-from=0.10.5 >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "~$INSTALL_EXIT_CODE" = "~4" ] \
|
||||||
|
|| die ""nvm install --reinstall-packages-from" should exit with code 4 when given the same version, got $INSTALL_EXIT_CODE"
|
||||||
|
|
|
@ -17,6 +17,9 @@ echo $(nvm_source "git") | grep "nvm.git$" > /dev/null || die "nvm_source withou
|
||||||
# nvm_source with script parameter returns the location of nvm.sh
|
# nvm_source with script parameter returns the location of nvm.sh
|
||||||
echo $(nvm_source "script") | grep "nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh"
|
echo $(nvm_source "script") | grep "nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh"
|
||||||
|
|
||||||
|
# nvm_source with script-nvm-exec parameter returns the location of nvm-exec
|
||||||
|
echo $(nvm_source "script-nvm-exec") | grep "nvm-exec$" > /dev/null || die "nvm_source \"script-nvm-exec\" should return the location of nvm.sh"
|
||||||
|
|
||||||
# nvm_source with any other parameter errors out and exits
|
# nvm_source with any other parameter errors out and exits
|
||||||
nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit"
|
nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit"
|
||||||
out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here
|
out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here
|
||||||
|
|
|
@ -23,7 +23,7 @@ npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||||
|
|
||||||
nvm ls 0.9 | grep v0.9.7 > /dev/null || die "nvm ls 0.9 didn't show v0.9.7"
|
nvm ls 0.9 | grep v0.9.7 > /dev/null || die "nvm ls 0.9 didn't show v0.9.7"
|
||||||
|
|
||||||
nvm install 0.9.12 --copy-packages-from=0.9 || die "nvm install 0.9.12 --copy-packages-from=0.9 failed"
|
nvm install 0.9.12 --reinstall-packages-from=0.9 || die "nvm install 0.9.12 --reinstall-packages-from=0.9 failed"
|
||||||
|
|
||||||
[ -d ../../v0.9.12 ] || die "nvm install 0.9.12 didn't install"
|
[ -d ../../v0.9.12 ] || die "nvm install 0.9.12 didn't install"
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
die () { echo $@ ; exit 1; }
|
|
||||||
|
|
||||||
. ../../../nvm.sh
|
|
||||||
|
|
||||||
nvm use 0.10.28 > /dev/null
|
|
||||||
|
|
||||||
EXPECTED_MSG="Can not copy packages from the current version of node."
|
|
||||||
ACTUAL_MSG="$(nvm copy-packages 0.10.28 2>&1 > /dev/null)"
|
|
||||||
[ "~$ACTUAL_MSG" = "~$EXPECTED_MSG" ] || die "'nvm use 0.10.28 && nvm copy-packages 0.10.28' did not fail with the right message: '$ACTUAL_MESSAGE'"
|
|
||||||
|
|
||||||
EXPECTED_ERROR_CODE="2"
|
|
||||||
ACTUAL_ERROR_CODE="$(nvm copy-packages 0.10.28 > /dev/null 2>&1 ; echo $?)"
|
|
||||||
[ "~$ACTUAL_ERROR_CODE" = "~$EXPECTED_ERROR_CODE" ] || die "'nvm use 0.10.28 && nvm copy-packages 0.10.28' did not fail with the right error code: expected '$EXPECTED_ERROR_CODE', got '$ACTUAL_ERROR_CODE'"
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm use 0.10.28 > /dev/null
|
||||||
|
|
||||||
|
EXPECTED_MSG="Can not reinstall packages from the current version of node."
|
||||||
|
ACTUAL_MSG="$(nvm reinstall-packages 0.10.28 2>&1 > /dev/null)"
|
||||||
|
[ "~$ACTUAL_MSG" = "~$EXPECTED_MSG" ] || die "'nvm use 0.10.28 && nvm reinstall-packages 0.10.28' did not fail with the right message: '$ACTUAL_MESSAGE'"
|
||||||
|
|
||||||
|
EXPECTED_ERROR_CODE="2"
|
||||||
|
ACTUAL_ERROR_CODE="$(nvm reinstall-packages 0.10.28 > /dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "~$ACTUAL_ERROR_CODE" = "~$EXPECTED_ERROR_CODE" ] || die "'nvm use 0.10.28 && nvm reinstall-packages 0.10.28' did not fail with the right error code: expected '$EXPECTED_ERROR_CODE', got '$ACTUAL_ERROR_CODE'"
|
||||||
|
|
|
@ -13,7 +13,7 @@ echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet
|
||||||
nvm use 0.10.29
|
nvm use 0.10.29
|
||||||
ORIGINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
|
ORIGINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
|
||||||
|
|
||||||
nvm copy-packages 0.10.28
|
nvm reinstall-packages 0.10.28
|
||||||
FINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
|
FINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
|
||||||
|
|
||||||
[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)"
|
[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)"
|
Loading…
Reference in New Issue