mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-05 12:09:26 +00:00
Compare commits
267 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ebdcdc4363 | ||
![]() |
b805de80cb | ||
![]() |
44f416d58f | ||
![]() |
3d1ccfec70 | ||
![]() |
f73ee40dfe | ||
![]() |
2d692d9d78 | ||
![]() |
8aebf86329 | ||
![]() |
39dad845cf | ||
![]() |
838d72688f | ||
![]() |
8ee6f30352 | ||
![]() |
1458de7293 | ||
![]() |
a1def71062 | ||
![]() |
eb81fba8f7 | ||
![]() |
7496a24bd6 | ||
![]() |
c64a0343af | ||
![]() |
643365a948 | ||
![]() |
6e894520ec | ||
![]() |
9e389eb9fe | ||
![]() |
151efc32f5 | ||
![]() |
bda1d2ec29 | ||
![]() |
e3528b0d9e | ||
![]() |
014a44e154 | ||
![]() |
c9215a127f | ||
![]() |
c92effc6da | ||
![]() |
1e2a7a8de4 | ||
![]() |
d4caf9fb67 | ||
![]() |
0ef20199dc | ||
![]() |
0d898b0aa4 | ||
![]() |
0181821b51 | ||
![]() |
f34fef96d8 | ||
![]() |
26ee4aafc0 | ||
![]() |
8746d63041 | ||
![]() |
b7e2d7d24d | ||
![]() |
58ffa407c2 | ||
![]() |
49abc9ce02 | ||
![]() |
15876280f7 | ||
![]() |
9f653cc196 | ||
![]() |
543b86c060 | ||
![]() |
ba01993ea6 | ||
![]() |
31e7d5b36a | ||
![]() |
17c68075e8 | ||
![]() |
3fcff872af | ||
![]() |
c07838fcc0 | ||
![]() |
fe1ed37520 | ||
![]() |
ae1c488fe1 | ||
![]() |
d9662f138f | ||
![]() |
071323847c | ||
![]() |
b7a93be02e | ||
![]() |
3543cd5d2f | ||
![]() |
d7035c5e61 | ||
![]() |
1f679fc055 | ||
![]() |
c37dbbecb4 | ||
![]() |
f81b6d6b7b | ||
![]() |
d57f7ea54a | ||
![]() |
759f86f946 | ||
![]() |
60c2f3705e | ||
![]() |
657192dd27 | ||
![]() |
98e40a8da5 | ||
![]() |
2da44f90d2 | ||
![]() |
88a50780fc | ||
![]() |
9419794b19 | ||
![]() |
b4151e1446 | ||
![]() |
f2d31b0458 | ||
![]() |
0b41352210 | ||
![]() |
be5e8de0c8 | ||
![]() |
3ef937a64e | ||
![]() |
a21b2e6962 | ||
![]() |
cc090f4476 | ||
![]() |
c31b072145 | ||
![]() |
7bce6c6c68 | ||
![]() |
fb2f1ac627 | ||
![]() |
bc3840b6f3 | ||
![]() |
6b8fd19d76 | ||
![]() |
c1ef31df53 | ||
![]() |
3b67b3b9bb | ||
![]() |
83466446ce | ||
![]() |
3214caa4ec | ||
![]() |
67f2ee82ca | ||
![]() |
1f13f15620 | ||
![]() |
fe044c5e3b | ||
![]() |
3cfa1ed4e1 | ||
![]() |
d78722b284 | ||
![]() |
4c475b2767 | ||
![]() |
a539cba11e | ||
![]() |
472ba5fc46 | ||
![]() |
96c96ec714 | ||
![]() |
475b8bd6b4 | ||
![]() |
5e805905ca | ||
![]() |
2dec01da9c | ||
![]() |
63672641a5 | ||
![]() |
94bba31de3 | ||
![]() |
f70530ef18 | ||
![]() |
ec33e8b720 | ||
![]() |
a4f89c6223 | ||
![]() |
517817f1a3 | ||
![]() |
a6f5eff0f3 | ||
![]() |
0aac462b15 | ||
![]() |
bb2fe618cb | ||
![]() |
eb5cecc970 | ||
![]() |
36f933984d | ||
![]() |
54d2d70048 | ||
![]() |
e1009149c9 | ||
![]() |
153ee6887e | ||
![]() |
295f2b7db4 | ||
![]() |
356ac7a697 | ||
![]() |
64c88ce62e | ||
![]() |
4612d8d827 | ||
![]() |
6644f33a77 | ||
![]() |
cbf0f12aac | ||
![]() |
de93dc46d0 | ||
![]() |
7ea15a7618 | ||
![]() |
6a114eddcc | ||
![]() |
e4149c380b | ||
![]() |
caa69bc500 | ||
![]() |
e01bcb740b | ||
![]() |
276d55c912 | ||
![]() |
0dc177bf9c | ||
![]() |
c34502ebc2 | ||
![]() |
3d764e6833 | ||
![]() |
a26ef4f1be | ||
![]() |
d68f667464 | ||
![]() |
c966204cd6 | ||
![]() |
d72b35b7b8 | ||
![]() |
d50a0f46e9 | ||
![]() |
82393f5b36 | ||
![]() |
a1a8e5a51b | ||
![]() |
108f630732 | ||
![]() |
96e73825bd | ||
![]() |
9fc20bb14b | ||
![]() |
3401d15a18 | ||
![]() |
394e8505d9 | ||
![]() |
fc86834e29 | ||
![]() |
609d9ee4ea | ||
![]() |
70370a857f | ||
![]() |
65a986c633 | ||
![]() |
3cc5d6af67 | ||
![]() |
999c4111c1 | ||
![]() |
3d69cf7437 | ||
![]() |
207521d54b | ||
![]() |
7750253bca | ||
![]() |
14b23bfa95 | ||
![]() |
bf7bd3e793 | ||
![]() |
2b63f37f8d | ||
![]() |
230b479648 | ||
![]() |
5802ac3ea7 | ||
![]() |
b18126cb15 | ||
![]() |
c16919becd | ||
![]() |
8ae7a37d43 | ||
![]() |
ceb66d1356 | ||
![]() |
16a730f4cc | ||
![]() |
f8064b259d | ||
![]() |
f8ee25ab5b | ||
![]() |
fb48129cd4 | ||
![]() |
9e154b159e | ||
![]() |
fb853614a7 | ||
![]() |
0d9329435c | ||
![]() |
a0d04d0b6b | ||
![]() |
6c1a310846 | ||
![]() |
758141f41e | ||
![]() |
7d22e0c458 | ||
![]() |
cd481ff548 | ||
![]() |
12ca8f2607 | ||
![]() |
e58d4abf11 | ||
![]() |
820074e1d7 | ||
![]() |
3d6b7976e7 | ||
![]() |
3190effedd | ||
![]() |
d0617b5b79 | ||
![]() |
286c808739 | ||
![]() |
f0d81e2d33 | ||
![]() |
4768973a85 | ||
![]() |
4508f7c33e | ||
![]() |
ea4264645b | ||
![]() |
a216f56443 | ||
![]() |
c8efe3d28a | ||
![]() |
0717d5f995 | ||
![]() |
6cfc309336 | ||
![]() |
dd1a9ca6a0 | ||
![]() |
4ba7ee5797 | ||
![]() |
40c9d6fd11 | ||
![]() |
2db71a85a5 | ||
![]() |
64b16faf72 | ||
![]() |
be56ff3b2e | ||
![]() |
59e27f8108 | ||
![]() |
0f1f3ed29c | ||
![]() |
2116d2ff91 | ||
![]() |
0b4c1e14cf | ||
![]() |
e1b7496cf0 | ||
![]() |
8a87133f71 | ||
![]() |
0792945824 | ||
![]() |
a6819b3018 | ||
![]() |
3d3d9d3a8d | ||
![]() |
3e74bac964 | ||
![]() |
1eaf6b53e4 | ||
![]() |
24c60e4e51 | ||
![]() |
8822bd719a | ||
![]() |
d90c1eca39 | ||
![]() |
223f388693 | ||
![]() |
cba5094652 | ||
![]() |
b5d9e547f2 | ||
![]() |
15598899b6 | ||
![]() |
c8f712a334 | ||
![]() |
2d9494af45 | ||
![]() |
2755227d40 | ||
![]() |
dd146519a2 | ||
![]() |
7243bd77d3 | ||
![]() |
7d113a2b2f | ||
![]() |
17df0b9912 | ||
![]() |
6cac732141 | ||
![]() |
9ee864b06f | ||
![]() |
0471d0ffd6 | ||
![]() |
43a7d78693 | ||
![]() |
879dda6c3d | ||
![]() |
ea12784629 | ||
![]() |
f1f11e3b7a | ||
![]() |
247bd310ef | ||
![]() |
dbeeb683da | ||
![]() |
39a75e616d | ||
![]() |
3cf68dc18d | ||
![]() |
654c37bc29 | ||
![]() |
c6a9f7baae | ||
![]() |
bb2564d6db | ||
![]() |
896a7eddd3 | ||
![]() |
8ae7b33632 | ||
![]() |
eb8c3414dd | ||
![]() |
9615672243 | ||
![]() |
78c1f2cf9d | ||
![]() |
ed22d3de2d | ||
![]() |
448bd38a55 | ||
![]() |
0ad5a450fe | ||
![]() |
d5e21be164 | ||
![]() |
797c5ab70b | ||
![]() |
952096d034 | ||
![]() |
dd3a3763ce | ||
![]() |
41c379839d | ||
![]() |
d9340b6a53 | ||
![]() |
b0d6c05d6e | ||
![]() |
0e209ce890 | ||
![]() |
9a57a891b9 | ||
![]() |
58ab2c3128 | ||
![]() |
d70f0357f5 | ||
![]() |
5143de9653 | ||
![]() |
5c336a7ccb | ||
![]() |
3d5ded1815 | ||
![]() |
f661617f1c | ||
![]() |
d28703f9e0 | ||
![]() |
b7983842aa | ||
![]() |
c12104cecd | ||
![]() |
98e0655198 | ||
![]() |
c46748a379 | ||
![]() |
8be97c8abb | ||
![]() |
7807a9f09e | ||
![]() |
835c006b5e | ||
![]() |
3fa11c35cb | ||
![]() |
34e51f9f02 | ||
![]() |
4b5885d69d | ||
![]() |
bf794ff8da | ||
![]() |
0bd7372c64 | ||
![]() |
0a142b7e7a | ||
![]() |
3fc82d6b2f | ||
![]() |
c6489440dc | ||
![]() |
67e8939311 | ||
![]() |
a26007ec0d | ||
![]() |
3f5ce8b93a | ||
![]() |
8328741792 | ||
![]() |
8e45afb9f1 | ||
![]() |
fd2fb24b03 | ||
![]() |
4708cc73ef |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sh eol=lf
|
11
.travis.yml
11
.travis.yml
@@ -1,17 +1,16 @@
|
||||
language: c # defaults to ruby
|
||||
addons:
|
||||
apt_packages:
|
||||
- zsh
|
||||
- ksh
|
||||
install:
|
||||
- sudo apt-get install zsh -y # ksh
|
||||
- (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s http://registry.npmjs.org/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*)
|
||||
- (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s https://registry.npmjs.com/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*)
|
||||
- chmod +x /tmp/urchin/package/urchin
|
||||
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
||||
script:
|
||||
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL
|
||||
env:
|
||||
- SHELL=sh TEST_SUITE=install_script
|
||||
- SHELL=dash TEST_SUITE=install_script
|
||||
- SHELL=bash TEST_SUITE=install_script
|
||||
- SHELL=zsh TEST_SUITE=install_script
|
||||
# - SHELL=ksh TEST_SUITE=install_script
|
||||
- SHELL=sh TEST_SUITE=fast
|
||||
- SHELL=dash TEST_SUITE=fast
|
||||
- SHELL=bash TEST_SUITE=fast
|
||||
|
@@ -4,19 +4,22 @@
|
||||
|
||||
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
||||
|
||||
Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Two alternatives exist, which are not supported nor developed by us:
|
||||
- [nvmw](http://github.com/hakobera/nvmw)
|
||||
- [nvm-windows](http://github.com/coreybutler/nvm-windows)
|
||||
Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Two alternatives exist, which are neither supported nor developed by us:
|
||||
- [nvmw](https://github.com/hakobera/nvmw)
|
||||
- [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
||||
|
||||
Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). An alternative exists, which is neither supported nor developed by us:
|
||||
- [bass](https://github.com/edc/bass) allows to use utilities written for Bash in fish shell
|
||||
|
||||
### Install script
|
||||
|
||||
To install you could use the [install script][2] using cURL:
|
||||
|
||||
curl https://raw.githubusercontent.com/creationix/nvm/v0.22.0/install.sh | bash
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.28.0/install.sh | bash
|
||||
|
||||
or Wget:
|
||||
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.22.0/install.sh | bash
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.28.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>
|
||||
|
||||
@@ -35,7 +38,7 @@ Or if you have `git` installed, then just clone it, and check out the latest ver
|
||||
|
||||
To activate nvm, you need to source it from your shell:
|
||||
|
||||
source ~/.nvm/nvm.sh
|
||||
. ~/.nvm/nvm.sh
|
||||
|
||||
I always add this line to my `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login.
|
||||
Often I also put in a line to use a specific version of node.
|
||||
@@ -72,6 +75,27 @@ In place of a version pointer like "0.10", you can use the special default alias
|
||||
nvm use stable
|
||||
nvm run unstable --version
|
||||
|
||||
If you want to install a new version of Node.js and migrate npm packages from a previous version:
|
||||
|
||||
nvm install node --reinstall-packages-from=node
|
||||
|
||||
This will first use "nvm version node" to identify the current version you're migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs "nvm reinstall-packages" to reinstall the npm packages from your prior version of Node to the new one.
|
||||
|
||||
You can also install and migrate npm packages from specific versions of Node like this:
|
||||
|
||||
nvm install v0.10.40 --reinstall-packages-from=0.10.39
|
||||
nvm install v0.12.7 --reinstall-packages-from=0.12.6
|
||||
|
||||
If you want to install [io.js](https://github.com/iojs/io.js/):
|
||||
|
||||
nvm install iojs
|
||||
|
||||
If you want to install a new version of io.js and migrate npm packages from a previous version:
|
||||
|
||||
nvm install iojs --reinstall-packages-from=iojs
|
||||
|
||||
The same guidelines mentioned for migrating npm packages in Node.js are applicable to io.js.
|
||||
|
||||
If you want to use the system-installed version of node, you can use the special default alias "system":
|
||||
|
||||
nvm use system
|
||||
@@ -95,10 +119,17 @@ To set a default Node version to be used in any new shell, use the alias 'defaul
|
||||
|
||||
To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
|
||||
|
||||
export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist
|
||||
export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
|
||||
nvm install 0.10
|
||||
|
||||
NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 0.10
|
||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 0.10
|
||||
|
||||
To use a mirror of the iojs binaries, set `$NVM_IOJS_ORG_MIRROR`:
|
||||
|
||||
export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
|
||||
nvm install iojs-v1.0.3
|
||||
|
||||
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3
|
||||
|
||||
`nvm use` will not, by default, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to "true" to enable this behavior, which is sometimes useful for IDEs.
|
||||
|
||||
@@ -172,17 +203,31 @@ nvm uninstall
|
||||
$ nvm uninstall [tab][tab]
|
||||
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||
|
||||
## Compatibility Issues
|
||||
`nvm` will encounter some issues if you have some non-default settings set. (see [#606](/../../issues/606))
|
||||
The following are known to cause issues:
|
||||
|
||||
Inside `~/.npmrc`
|
||||
```
|
||||
prefix='some/path'
|
||||
```
|
||||
Environment Variables:
|
||||
```
|
||||
$NPM_CONFIG_PREFIX
|
||||
$PREFIX
|
||||
```
|
||||
|
||||
## Problems
|
||||
|
||||
If you try to install a node version and the installation fails, be sure to delete the node downloads from src (~/.nvm/src/) or you might get an error when trying to reinstall them again or you might get an error like the following:
|
||||
|
||||
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
|
||||
|
||||
Where's my 'sudo node'? Checkout this link:
|
||||
Where's my 'sudo node'? Check out this link:
|
||||
|
||||
https://github.com/creationix/nvm/issues/43
|
||||
|
||||
on Arch Linux and other systems using python3 by default, before running *install* you need to
|
||||
On Arch Linux and other systems using python3 by default, before running *install* you need to
|
||||
|
||||
export PYTHON=python2
|
||||
|
||||
@@ -191,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
|
||||
|
||||
[1]: https://github.com/creationix/nvm.git
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.22.0/install.sh
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.28.0/install.sh
|
||||
[3]: https://travis-ci.org/creationix/nvm
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
|
||||
[Fish]: http://fishshell.com
|
||||
|
@@ -57,7 +57,7 @@ __nvm_aliases ()
|
||||
declare aliases
|
||||
aliases=""
|
||||
if [ -d $NVM_DIR/alias ]; then
|
||||
aliases="`cd $NVM_DIR/alias && ls`"
|
||||
aliases="`cd $NVM_DIR/alias && command ls`"
|
||||
fi
|
||||
echo "${aliases}"
|
||||
}
|
||||
@@ -73,7 +73,7 @@ __nvm ()
|
||||
previous_word="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
case "$previous_word" in
|
||||
use|run|ls|list|uninstall) __nvm_installed_nodes ;;
|
||||
use|run|exec|ls|list|uninstall) __nvm_installed_nodes ;;
|
||||
alias|unalias) __nvm_alias ;;
|
||||
*) __nvm_commands ;;
|
||||
esac
|
||||
|
171
install.sh
171
install.sh
@@ -1,51 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
{ # this ensures the entire script is downloaded #
|
||||
|
||||
nvm_has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
if [ -z "$NVM_DIR" ]; then
|
||||
NVM_DIR="$HOME/.nvm"
|
||||
fi
|
||||
|
||||
nvm_latest_version() {
|
||||
echo "v0.28.0"
|
||||
}
|
||||
|
||||
#
|
||||
# Outputs the location to NVM depending on:
|
||||
# * The availability of $NVM_SOURCE
|
||||
# * The method used ("script" or "git" in the script, defaults to "git")
|
||||
# NVM_SOURCE always takes precedence
|
||||
# NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"
|
||||
#
|
||||
nvm_source() {
|
||||
local NVM_METHOD
|
||||
NVM_METHOD="$1"
|
||||
if [ -z "$NVM_SOURCE" ]; then
|
||||
local NVM_SOURCE
|
||||
else
|
||||
echo "$NVM_SOURCE"
|
||||
return 0
|
||||
local NVM_SOURCE_URL
|
||||
NVM_SOURCE_URL="$NVM_SOURCE"
|
||||
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
|
||||
elif [ -z "$NVM_SOURCE_URL" ]; then
|
||||
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
|
||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||
NVM_SOURCE_URL="https://github.com/creationix/nvm.git"
|
||||
else
|
||||
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm.sh"
|
||||
elif [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm-exec"
|
||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||
else
|
||||
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
||||
return 1
|
||||
fi
|
||||
echo "$NVM_SOURCE"
|
||||
return 0
|
||||
echo "$NVM_SOURCE_URL"
|
||||
}
|
||||
|
||||
nvm_download() {
|
||||
if nvm_has "curl"; then
|
||||
curl $*
|
||||
curl -q $*
|
||||
elif nvm_has "wget"; then
|
||||
# Emulate curl with wget
|
||||
ARGS=$(echo "$*" | sed -e 's/--progress-bar /--progress=bar /' \
|
||||
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||
-e 's/-L //' \
|
||||
-e 's/-I /--server-response /' \
|
||||
-e 's/-s /-q /' \
|
||||
@@ -57,9 +57,9 @@ nvm_download() {
|
||||
|
||||
install_nvm_from_git() {
|
||||
if [ -d "$NVM_DIR/.git" ]; then
|
||||
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
||||
echo "=> nvm is already installed in $NVM_DIR, trying to update using git"
|
||||
printf "\r=> "
|
||||
cd "$NVM_DIR" && (git fetch 2> /dev/null || {
|
||||
cd "$NVM_DIR" && (command git fetch 2> /dev/null || {
|
||||
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
|
||||
})
|
||||
else
|
||||
@@ -67,27 +67,35 @@ install_nvm_from_git() {
|
||||
echo "=> Downloading nvm from git to '$NVM_DIR'"
|
||||
printf "\r=> "
|
||||
mkdir -p "$NVM_DIR"
|
||||
git clone "$(nvm_source "git")" "$NVM_DIR"
|
||||
command git clone "$(nvm_source git)" "$NVM_DIR"
|
||||
fi
|
||||
cd "$NVM_DIR" && command git checkout --quiet $(nvm_latest_version)
|
||||
if [ ! -z "$(cd "$NVM_DIR" && git show-ref refs/heads/master)" ]; then
|
||||
if git branch --quiet 2>/dev/null; then
|
||||
cd "$NVM_DIR" && command git branch --quiet -D master >/dev/null 2>&1
|
||||
else
|
||||
echo >&2 "Your version of git is out of date. Please update it!"
|
||||
cd "$NVM_DIR" && command git branch -D master >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
cd "$NVM_DIR" && git checkout --quiet v0.22.0 && git branch --quiet -D master >/dev/null 2>&1
|
||||
return
|
||||
}
|
||||
|
||||
install_nvm_as_script() {
|
||||
local NVM_SOURCE
|
||||
NVM_SOURCE=$(nvm_source "script")
|
||||
local NVM_SOURCE_LOCAL
|
||||
NVM_SOURCE_LOCAL=$(nvm_source script)
|
||||
local NVM_EXEC_SOURCE
|
||||
NVM_EXEC_SOURCE=$(nvm_source "script-nvm-exec")
|
||||
NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
|
||||
|
||||
# Downloading to $NVM_DIR
|
||||
mkdir -p "$NVM_DIR"
|
||||
if [ -d "$NVM_DIR/nvm.sh" ]; then
|
||||
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
||||
echo "=> nvm is already installed in $NVM_DIR, trying to update the script"
|
||||
else
|
||||
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||
fi
|
||||
nvm_download -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
|
||||
echo >&2 "Failed to download '$NVM_SOURCE'"
|
||||
nvm_download -s "$NVM_SOURCE_LOCAL" -o "$NVM_DIR/nvm.sh" || {
|
||||
echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
|
||||
return 1
|
||||
}
|
||||
nvm_download -s "$NVM_EXEC_SOURCE" -o "$NVM_DIR/nvm-exec" || {
|
||||
@@ -107,16 +115,85 @@ install_nvm_as_script() {
|
||||
# Otherwise, an empty string is returned
|
||||
#
|
||||
nvm_detect_profile() {
|
||||
if [ -f "$PROFILE" ]; then
|
||||
echo "$PROFILE"
|
||||
elif [ -f "$HOME/.bashrc" ]; then
|
||||
echo "$HOME/.bashrc"
|
||||
elif [ -f "$HOME/.bash_profile" ]; then
|
||||
echo "$HOME/.bash_profile"
|
||||
elif [ -f "$HOME/.zshrc" ]; then
|
||||
echo "$HOME/.zshrc"
|
||||
elif [ -f "$HOME/.profile" ]; then
|
||||
echo "$HOME/.profile"
|
||||
|
||||
local DETECTED_PROFILE
|
||||
DETECTED_PROFILE=''
|
||||
local SHELLTYPE
|
||||
SHELLTYPE="$(basename /$SHELL)"
|
||||
|
||||
if [ $SHELLTYPE = "bash" ]; then
|
||||
if [ -f "$HOME/.bashrc" ]; then
|
||||
DETECTED_PROFILE="$HOME/.bashrc"
|
||||
elif [ -f "$HOME/.bash_profile" ]; then
|
||||
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||
fi
|
||||
elif [ $SHELLTYPE = "zsh" ]; then
|
||||
DETECTED_PROFILE="$HOME/.zshrc"
|
||||
fi
|
||||
|
||||
if [ -z $DETECTED_PROFILE ]; then
|
||||
if [ -f "$PROFILE" ]; then
|
||||
DETECTED_PROFILE="$PROFILE"
|
||||
elif [ -f "$HOME/.profile" ]; then
|
||||
DETECTED_PROFILE="$HOME/.profile"
|
||||
elif [ -f "$HOME/.bashrc" ]; then
|
||||
DETECTED_PROFILE="$HOME/.bashrc"
|
||||
elif [ -f "$HOME/.bash_profile" ]; then
|
||||
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||
elif [ -f "$HOME/.zshrc" ]; then
|
||||
DETECTED_PROFILE="$HOME/.zshrc"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z $DETECTED_PROFILE ]; then
|
||||
echo "$DETECTED_PROFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Check whether the user has any globally-installed npm modules in their system
|
||||
# Node, and warn them if so.
|
||||
#
|
||||
nvm_check_global_modules() {
|
||||
command -v npm >/dev/null 2>&1 || return 0
|
||||
|
||||
local NPM_VERSION
|
||||
NPM_VERSION="$(npm --version)"
|
||||
NPM_VERSION="${NPM_VERSION:--1}"
|
||||
[ "${NPM_VERSION%%[!-0-9]*}" -gt 0 ] || return 0
|
||||
|
||||
local NPM_GLOBAL_MODULES
|
||||
NPM_GLOBAL_MODULES="$(
|
||||
npm list -g --depth=0 |
|
||||
sed '/ npm@/d' |
|
||||
sed '/ (empty)$/d'
|
||||
)"
|
||||
|
||||
local MODULE_COUNT
|
||||
MODULE_COUNT="$(
|
||||
printf %s\\n "$NPM_GLOBAL_MODULES" |
|
||||
sed -ne '1!p' | # Remove the first line
|
||||
wc -l | tr -d ' ' # Count entries
|
||||
)"
|
||||
|
||||
if [ $MODULE_COUNT -ne 0 ]; then
|
||||
cat <<-'END_MESSAGE'
|
||||
=> You currently have modules installed globally with `npm`. These will no
|
||||
=> longer be linked to the active version of Node when you install a new node
|
||||
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
|
||||
=> override the binaries of modules installed with `nvm`:
|
||||
|
||||
END_MESSAGE
|
||||
printf %s\\n "$NPM_GLOBAL_MODULES"
|
||||
cat <<-'END_MESSAGE'
|
||||
|
||||
=> If you wish to uninstall them at a later point (or re-install them under your
|
||||
=> `nvm` Nodes), you can remove them from the system Node as follows:
|
||||
|
||||
$ nvm use system
|
||||
$ npm uninstall -g a_module
|
||||
|
||||
END_MESSAGE
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -161,7 +238,7 @@ nvm_do_install() {
|
||||
printf "$SOURCE_STR"
|
||||
echo
|
||||
else
|
||||
if ! grep -qc 'nvm.sh' "$NVM_PROFILE"; then
|
||||
if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then
|
||||
echo "=> Appending source string to $NVM_PROFILE"
|
||||
printf "$SOURCE_STR\n" >> "$NVM_PROFILE"
|
||||
else
|
||||
@@ -169,6 +246,8 @@ nvm_do_install() {
|
||||
fi
|
||||
fi
|
||||
|
||||
nvm_check_global_modules
|
||||
|
||||
echo "=> Close and reopen your terminal to start using nvm"
|
||||
nvm_reset
|
||||
}
|
||||
@@ -178,7 +257,11 @@ nvm_do_install() {
|
||||
# during the execution of the install script
|
||||
#
|
||||
nvm_reset() {
|
||||
unset -f nvm_do_install nvm_has nvm_download install_nvm_as_script install_nvm_from_git nvm_reset nvm_detect_profile
|
||||
unset -f nvm_reset nvm_has nvm_latest_version \
|
||||
nvm_source nvm_download install_nvm_as_script install_nvm_from_git \
|
||||
nvm_detect_profile nvm_check_global_modules nvm_do_install
|
||||
}
|
||||
|
||||
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
||||
|
||||
} # this ensures the entire script is downloaded #
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.22.0",
|
||||
"version": "0.28.0",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
@@ -30,8 +30,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/creationix/nvm",
|
||||
"devDependencies": {
|
||||
"replace": "~0.3.0",
|
||||
"semver": "~4.1.1",
|
||||
"urchin": "~0.0.5"
|
||||
"replace": "^0.3.0",
|
||||
"semver": "^5.0.1",
|
||||
"urchin": "^0.0.5"
|
||||
}
|
||||
}
|
||||
|
13
test/common.sh
Normal file
13
test/common.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
assert_ok() {
|
||||
local FUNCTION=$1
|
||||
shift
|
||||
|
||||
$($FUNCTION $@) || die '"'"$FUNCTION $@"'" should have succeeded, but failed'
|
||||
}
|
||||
|
||||
assert_not_ok() {
|
||||
local FUNCTION=$1
|
||||
shift
|
||||
|
||||
! $($FUNCTION $@) || die '"'"$FUNCTION $@"'" should have failed, but succeeded'
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
# set clobber option in order to test that this does not produce any
|
||||
# incompatibilities
|
||||
setopt noclobber
|
||||
fi
|
||||
|
||||
nvm alias test-stable-1 0.0.2
|
||||
|
||||
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.2 (-> v0.0.2)" \
|
||||
|| die "nvm alias test-stable-1 0.0.2 did not set test-stable-1 to 0.0.2"
|
||||
|
||||
nvm alias test-stable-1 0.0.1
|
||||
|
||||
nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.1 (-> v0.0.1)" \
|
||||
|| die "nvm alias test-stable-1 0.0.1 did not set test-stable-1 to 0.0.1"
|
@@ -11,8 +11,16 @@ STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_STABLE (-> $STABLE_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local stable node version"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^node -> stable (-> $STABLE_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local stable node version under 'node'"
|
||||
|
||||
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local unstable node version"
|
||||
|
||||
EXPECTED_IOJS="$(nvm_print_implicit_alias local iojs)"
|
||||
IOJS_VERSION="$(nvm_version "$EXPECTED_IOJS")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^iojs -> $EXPECTED_IOJS (-> $IOJS_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local iojs version"
|
||||
|
||||
|
@@ -6,12 +6,16 @@ die () { echo $@ ; cleanup ; exit 1; }
|
||||
cleanup () {
|
||||
rm -rf ../../../alias/stable
|
||||
rm -rf ../../../alias/unstable
|
||||
rm -rf ../../../alias/node
|
||||
rm -rf ../../../alias/iojs
|
||||
rm -rf ../../../v0.8.1
|
||||
rm -rf ../../../v0.9.1
|
||||
rm -rf ../../../versions/io.js/v0.2.1
|
||||
}
|
||||
|
||||
mkdir ../../../v0.8.1
|
||||
mkdir ../../../v0.9.1
|
||||
mkdir -p ../../../versions/io.js/v0.2.1
|
||||
|
||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
@@ -24,14 +28,22 @@ UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||
|
||||
nvm alias stable "$EXPECTED_UNSTABLE"
|
||||
nvm alias unstable "$EXPECTED_STABLE"
|
||||
nvm alias node stable
|
||||
nvm alias iojs unstable
|
||||
|
||||
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'stable' alias"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'unstable' alias"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^node -> stable (-> $UNSTABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'node' alias"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | command grep -e "^iojs -> unstable (-> $STABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'iojs' alias"
|
||||
|
||||
cleanup
|
||||
|
||||
|
36
test/fast/Aliases/circular/nvm_resolve_local_alias
Executable file
36
test/fast/Aliases/circular/nvm_resolve_local_alias
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../../nvm.sh
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias loopback)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias loopback was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias loopback)"
|
||||
EXPECTED_OUTPUT="loopback -> loopback (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias loopback was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias one)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias one was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias one)"
|
||||
EXPECTED_OUTPUT="one -> two (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias one was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias two)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias two was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias two)"
|
||||
EXPECTED_OUTPUT="two -> three (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias two was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias three)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias three was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias three)"
|
||||
EXPECTED_OUTPUT="three -> one (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias three was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
||||
ALIAS="$(nvm_resolve_local_alias four)"
|
||||
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_alias four was not ∞; got $ALIAS"
|
||||
OUTPUT="$(nvm alias four)"
|
||||
EXPECTED_OUTPUT="four -> two (-> ∞)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias four was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||
|
18
test/fast/Aliases/nvm_ensure_default_set
Executable file
18
test/fast/Aliases/nvm_ensure_default_set
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm alias default 0.1 >/dev/null || die "'nvm alias default 0.1' failed"
|
||||
|
||||
nvm_ensure_default_set 0.3 || die "'nvm_ensure_default_set' with an existing default alias exits 0"
|
||||
|
||||
nvm unalias default || die "'nvm unalias default' failed"
|
||||
|
||||
OUTPUT="$(nvm_ensure_default_set 0.2)"
|
||||
EXPECTED_OUTPUT="Creating default alias: default -> 0.2 (-> iojs-v0.2.10)"
|
||||
EXIT_CODE="$?"
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set 0.2' did not output '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "'nvm_ensure_default_set 0.2' did not exit with 0, got $EXIT_CODE"
|
@@ -21,8 +21,13 @@ EXIT_CODE=$(nvm_resolve_alias nonexistent ; echo $?)
|
||||
[ $EXIT_CODE = "2" ] || die "'nvm_resolve_alias nonexistent' did not return 2; got $EXIT_CODE"
|
||||
|
||||
STABLE="$(nvm_resolve_alias stable)"
|
||||
[ "_$STABLE" = "_v0.0.10" ] || die "'nvm_resolve_alias stable' was not v0.0.10; got $STABLE"
|
||||
[ "_$STABLE" = "_v0.0" ] || die "'nvm_resolve_alias stable' was not v0.0; got $STABLE"
|
||||
|
||||
NODE="$(nvm_resolve_alias node)"
|
||||
[ "_$NODE" = "_stable" ] || die "'nvm_resolve_alias node' was not stable; got $NODE"
|
||||
|
||||
UNSTABLE="$(nvm_resolve_alias unstable)"
|
||||
[ "_$UNSTABLE" = "_v0.1.10" ] || die "'nvm_resolve_alias unstable' was not v0.1.10; got $UNSTABLE"
|
||||
[ "_$UNSTABLE" = "_v0.1" ] || die "'nvm_resolve_alias unstable' was not v0.1; got $UNSTABLE"
|
||||
|
||||
IOJS="$(nvm_resolve_alias iojs)"
|
||||
[ "_$IOJS" = "_iojs-v0.2" ] || die "'nvm_resolve_alias iojs' was not iojs-v0.2; got $IOJS"
|
||||
|
35
test/fast/Aliases/nvm_resolve_local_alias
Executable file
35
test/fast/Aliases/nvm_resolve_local_alias
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
EXIT_CODE=$(nvm_resolve_local_alias ; echo $?)
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "nvm_resolve_local_alias without an argument did not return 1; got $EXIT_CODE"
|
||||
|
||||
for i in $(seq 1 10)
|
||||
do
|
||||
STABLE_ALIAS="$(nvm_resolve_local_alias test-stable-$i)"
|
||||
[ "_$STABLE_ALIAS" = "_v0.0.$i" ] \
|
||||
|| die "'nvm_resolve_local_alias test-stable-$i' was not v0.0.$i; got $STABLE_ALIAS"
|
||||
UNSTABLE_ALIAS="$(nvm_resolve_local_alias test-unstable-$i)"
|
||||
[ "_$UNSTABLE_ALIAS" = "_v0.1.$i" ] \
|
||||
|| die "'nvm_resolve_local_alias test-unstable-$i' was not v0.1.$i; got $UNSTABLE_ALIAS"
|
||||
done
|
||||
|
||||
OUTPUT="$(nvm_resolve_local_alias nonexistent)"
|
||||
EXIT_CODE=$(nvm_resolve_local_alias nonexistent > /dev/null 2>&1 ; echo $?)
|
||||
[ "_$EXIT_CODE" = "_2" ] || die "'nvm_resolve_local_alias nonexistent' did not return 2; got $EXIT_CODE"
|
||||
[ "_$OUTPUT" = "_" ] || die "'nvm_resolve_local_alias nonexistent' did not have empty output; got $OUTPUT"
|
||||
|
||||
STABLE="$(nvm_resolve_local_alias stable)"
|
||||
[ "_$STABLE" = "_v0.0.10" ] || die "'nvm_resolve_local_alias stable' was not v0.0.10; got $STABLE"
|
||||
|
||||
NODE="$(nvm_resolve_local_alias node)"
|
||||
[ "_$NODE" = "_v0.0.10" ] || die "'nvm_resolve_local_alias node' was not v0.0.10; got $NODE"
|
||||
|
||||
UNSTABLE="$(nvm_resolve_local_alias unstable)"
|
||||
[ "_$UNSTABLE" = "_v0.1.10" ] || die "'nvm_resolve_local_alias unstable' was not v0.1.10; got $UNSTABLE"
|
||||
|
||||
IOJS="$(nvm_resolve_local_alias iojs)"
|
||||
[ "_$IOJS" = "_iojs-v0.2.10" ] || die "'nvm_resolve_local_alias iojs' was not iojs-v0.2.10; got $IOJS"
|
@@ -6,4 +6,6 @@ for i in $(seq 1 10)
|
||||
mkdir -p ../../../v0.0.$i
|
||||
echo 0.1.$i > ../../../alias/test-unstable-$i
|
||||
mkdir -p ../../../v0.1.$i
|
||||
echo 0.2.$i > ../../../alias/test-iojs-$i
|
||||
mkdir -p ../../../versions/io.js/v0.2.$i
|
||||
done
|
||||
|
@@ -6,8 +6,12 @@ for i in $(seq 1 10)
|
||||
rm -rf "../../../v0.0.$i"
|
||||
rm -f "../../../alias/test-unstable-$i"
|
||||
rm -rf "../../../v0.1.$i"
|
||||
rm -rf "../../../alias/test-iojs-$i"
|
||||
rm -rf "../../../versions/io.js/v0.2.$i"
|
||||
done
|
||||
|
||||
rm -f "../../../alias/stable"
|
||||
rm -f "../../../alias/unstable"
|
||||
|
||||
rm -f "../../../alias/node"
|
||||
rm -f "../../../alias/iojs"
|
||||
rm -f "../../../alias/default"
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
mkdir -p ../../../v0.0.2
|
||||
mkdir -p ../../../v0.0.20
|
||||
mkdir -p ../../../versions/v0.12.0
|
||||
mkdir -p ../../../versions/node/v0.12.0
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
|
@@ -2,6 +2,6 @@
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls node
|
||||
nvm ls io
|
||||
[ "$?" = "3" ]
|
||||
|
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls node_
|
||||
[ "$?" = "3" ]
|
||||
|
@@ -8,11 +8,17 @@ mkdir ../../../v0.0.9
|
||||
mkdir ../../../v0.3.1
|
||||
mkdir ../../../v0.3.3
|
||||
mkdir ../../../v0.3.9
|
||||
mkdir -p ../../../versions/node/v0.12.87
|
||||
mkdir -p ../../../versions/node/v0.12.9
|
||||
mkdir -p ../../../versions/io.js/v0.1.2
|
||||
mkdir -p ../../../versions/io.js/v0.10.2
|
||||
|
||||
# The result should contain the version numbers.
|
||||
nvm ls | grep v0.0.1 &&
|
||||
nvm ls | grep v0.0.3 &&
|
||||
nvm ls | grep v0.0.9 &&
|
||||
nvm ls | grep v0.3.1 &&
|
||||
nvm ls | grep v0.3.3 &&
|
||||
nvm ls | grep v0.3.9
|
||||
nvm ls | grep v0.0.1 >/dev/null &&
|
||||
nvm ls | grep v0.0.3 >/dev/null &&
|
||||
nvm ls | grep v0.0.9 >/dev/null &&
|
||||
nvm ls | grep v0.3.1 >/dev/null &&
|
||||
nvm ls | grep v0.3.3 >/dev/null &&
|
||||
nvm ls | grep v0.3.9 >/dev/null &&
|
||||
nvm ls | grep v0.12.87 >/dev/null &&
|
||||
nvm ls | grep iojs-v0.1.2 >/dev/null
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
mkdir ../../../v0.1.3
|
||||
mkdir ../../../v0.2.3
|
||||
mkdir ../../../versions
|
||||
mkdir -p ../../../versions/node
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
mkdir -p ../../../versions/v0.12.1
|
||||
mkdir -p ../../../versions/node/v0.12.1
|
||||
mkdir ../../../v0.1.3
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
@@ -7,7 +7,7 @@ die () { echo $@ ; exit 1; }
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||
|
||||
. ../../nvm.sh
|
||||
nvm use v0.2.3 || die "Failed to activate v0.2.3"
|
||||
nvm use --delete-prefix v0.2.3 || die "Failed to activate v0.2.3"
|
||||
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` != 0 ] || die "PATH not set up properly"
|
||||
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
|
||||
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
|
||||
|
@@ -18,5 +18,13 @@ EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'
|
||||
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"
|
||||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm use --silent foo 2>&1)"
|
||||
EXPECTED_OUTPUT=''
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"
|
||||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"
|
||||
|
||||
cleanup;
|
||||
|
||||
|
38
test/fast/Running "nvm use iojs" uses latest io.js version
Executable file
38
test/fast/Running "nvm use iojs" uses latest io.js version
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
rm -rf ../../alias/foo
|
||||
}
|
||||
|
||||
. ../../nvm.sh
|
||||
|
||||
echo 'foo' > ../../alias/foo
|
||||
|
||||
OUTPUT="$(nvm use foo 2>&1)"
|
||||
EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"
|
||||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm use --silent foo 2>&1)"
|
||||
EXPECTED_OUTPUT=''
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm use foo --silent 2>&1)"
|
||||
EXPECTED_OUTPUT=''
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use foo --silent' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"
|
||||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"
|
||||
|
||||
EXIT_CODE="$(nvm use foo --silent 2>/dev/null ; echo $?)"
|
||||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use foo --silent'; got $EXIT_CODE"
|
||||
|
||||
cleanup;
|
||||
|
@@ -5,9 +5,18 @@ die () { echo $@ ; exit 1; }
|
||||
. ../../nvm.sh
|
||||
|
||||
nvm_has_system_node() { return 0; }
|
||||
[ "$(nvm use system 2>&1 | tail -n1)" = "Now using system version of node: $(node -v)." ] || die "Could not use system version of node"
|
||||
nvm_print_npm_version() { return ' (npm v1.2.3)'; }
|
||||
EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)"
|
||||
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node"
|
||||
EXPECTED_OUTPUT=""
|
||||
[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node or --silent was not silent"
|
||||
|
||||
nvm_has_system_node() { return 1; }
|
||||
[ "$(nvm use system 2>&1 | tail -n1)" = "System version of node not found." ] || die "Did not report error, system node not found"
|
||||
nvm_print_npm_version() { return ''; }
|
||||
EXPECTED_OUTPUT="System version of node not found."
|
||||
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found"
|
||||
nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"
|
||||
EXPECTED_OUTPUT=""
|
||||
[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found or --silent was not silent"
|
||||
nvm use --silent system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found or --silent was not silent"
|
||||
|
||||
|
17
test/fast/Unit tests/iojs_version_has_solaris_binary
Executable file
17
test/fast/Unit tests/iojs_version_has_solaris_binary
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
assert_not_ok iojs_version_has_solaris_binary ""
|
||||
assert_not_ok iojs_version_has_solaris_binary "foo"
|
||||
assert_not_ok iojs_version_has_solaris_binary "v1.1.0"
|
||||
|
||||
assert_ok iojs_version_has_solaris_binary "v3.3.1"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.3.1"
|
||||
assert_ok iojs_version_has_solaris_binary "v3.3.2"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.3.2"
|
||||
assert_ok iojs_version_has_solaris_binary "v3.4.1"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.4.1"
|
33
test/fast/Unit tests/node_version_has_solaris_binary
Executable file
33
test/fast/Unit tests/node_version_has_solaris_binary
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
# Invalid version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary ""
|
||||
assert_not_ok node_version_has_solaris_binary "foo"
|
||||
|
||||
# "Invalid" node version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary "v1.0.0"
|
||||
assert_not_ok node_version_has_solaris_binary "v3.3.1"
|
||||
|
||||
# Valid io.js version numbers that have a Solaris binary fail
|
||||
assert_not_ok node_version_has_solaris_binary "iojs-v3.3.1"
|
||||
|
||||
# Invvalid io.js version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary "iojs-v0.12.7"
|
||||
|
||||
# Valid node version numbers that don't have a Solaris binary fail
|
||||
assert_not_ok node_version_has_solaris_binary "v0.8.5"
|
||||
|
||||
# Valid node version numbers that have a Solaris binary succeed
|
||||
assert_ok node_version_has_solaris_binary "v0.8.6"
|
||||
assert_ok node_version_has_solaris_binary "v0.10.0"
|
||||
assert_ok node_version_has_solaris_binary "v0.12.7"
|
||||
|
||||
# Valid "merged" version numbers fail, because they're not
|
||||
# considered node version numbers
|
||||
assert_not_ok node_version_has_solaris_binary "v4.0.0"
|
||||
assert_not_ok node_version_has_solaris_binary "v4.1.1"
|
9
test/fast/Unit tests/nvm_add_iojs_prefix
Executable file
9
test/fast/Unit tests/nvm_add_iojs_prefix
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "_$(nvm_add_iojs_prefix 1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix 1" did not return "iojs-v1"'
|
||||
[ "_$(nvm_add_iojs_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix iojs-1" did not return "iojs-v1"'
|
||||
[ "_$(nvm_add_iojs_prefix iojs-1.2.3)" = "_iojs-v1.2.3" ] || die '"nvm_add_iojs_prefix iojs-1.2.3" did not return "iojs-v1.2.3"'
|
8
test/fast/Unit tests/nvm_alias_path
Executable file
8
test/fast/Unit tests/nvm_alias_path
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "_$(nvm_alias_path)" = "_$NVM_DIR/alias" ] || die "nvm_alias_path did not requrn correct location"
|
||||
|
74
test/fast/Unit tests/nvm_die_on_prefix
Executable file
74
test/fast/Unit tests/nvm_die_on_prefix
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
alias nvm_has='\nvm_has'
|
||||
alias npm='\npm'
|
||||
unset -f nvm_has npm
|
||||
}
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
OUTPUT="$(nvm_die_on_prefix 2>&1)"
|
||||
EXPECTED_OUTPUT="First argument \"delete the prefix\" must be zero or one"
|
||||
EXIT_CODE="$(nvm_die_on_prefix >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_die_on_prefix' did not exit with 1; got "$EXIT_CODE""
|
||||
|
||||
OUTPUT="$(nvm_die_on_prefix 2 2>&1)"
|
||||
EXPECTED_OUTPUT="First argument \"delete the prefix\" must be zero or one"
|
||||
EXIT_CODE="$(nvm_die_on_prefix 2 >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 2' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_die_on_prefix' did not exit with 1; got "$EXIT_CODE""
|
||||
|
||||
OUTPUT="$(nvm_die_on_prefix 0 2>&1)"
|
||||
EXPECTED_OUTPUT="Second argument \"nvm command\" must be nonempty"
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_2" ] || die "'nvm_die_on_prefix 0' did not exit with 2; got '$EXIT_CODE'"
|
||||
|
||||
nvm_has() { return 1; } # ie, npm is not installed
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||
[ -z "$OUTPUT" ] || die "nvm_die_on_prefix was not a noop when nvm_has returns 1, got '$OUTPUT'"
|
||||
|
||||
nvm_has() { return 0; }
|
||||
|
||||
npm() {
|
||||
local args
|
||||
args="$@"
|
||||
if [ "_$args" = "_config get prefix" ]; then
|
||||
echo "$(nvm_version_dir new)/good prefix"
|
||||
fi
|
||||
}
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||
[ -z "$OUTPUT" ] || die "'nvm_die_on_prefix' was not a noop when prefix is good; got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"
|
||||
EXPECTED_OUTPUT='nvm is not compatible with the "PREFIX" environment variable: currently set to "bar"
|
||||
Run `unset PREFIX` to unset it.'
|
||||
EXIT_CODE="$(PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 3; got '$EXIT_CODE'"
|
||||
|
||||
OUTPUT="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"
|
||||
EXPECTED_OUTPUT='nvm is not compatible with the "NPM_CONFIG_PREFIX" environment variable: currently set to "bar"
|
||||
Run `unset NPM_CONFIG_PREFIX` to unset it.'
|
||||
EXIT_CODE="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_4" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"
|
||||
|
||||
npm() {
|
||||
local args
|
||||
args="$@"
|
||||
if [ "_$args" = "_config get prefix" ]; then
|
||||
echo "./bad prefix"
|
||||
fi
|
||||
}
|
||||
OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
||||
EXPECTED_OUTPUT="nvm is not compatible with the npm config \"prefix\" option: currently set to \"./bad prefix\"
|
||||
Run \`npm config delete prefix\` or \`foo\` to unset it."
|
||||
EXIT_CODE="$(nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT' with bad prefix set; got '$OUTPUT'"
|
||||
[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' did not exit with 10 with bad prefix set; got '$EXIT_CODE'"
|
||||
|
||||
cleanup
|
13
test/fast/Unit tests/nvm_ensure_default_set
Executable file
13
test/fast/Unit tests/nvm_ensure_default_set
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
EXPECTED_OUTPUT="nvm_ensure_default_set: a version is required"
|
||||
OUTPUT="$(nvm_ensure_default_set 2>&1 >/dev/null)"
|
||||
EXIT_CODE="$?"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set' did not output "$EXPECTED_OUTPUT", got "$OUTPUT""
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_ensure_default_set' did not exit with 1, got "$EXIT_CODE""
|
||||
|
||||
# see test/fast/Aliases for remaining nvm_ensure_default_set tests
|
30
test/fast/Unit tests/nvm_ensure_version_installed
Executable file
30
test/fast/Unit tests/nvm_ensure_version_installed
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
cleanup () {
|
||||
rm -rf "$(nvm_version_path v0.1.2)"
|
||||
}
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
mkdir -p "$(nvm_version_path v0.1.2)"
|
||||
|
||||
OUTPUT="$(nvm_ensure_version_installed foo 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT='N/A: version "foo" is not yet installed'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed foo' to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed foo' to exit with 1, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_ensure_version_installed 0.1)"
|
||||
EXIT_CODE=$?
|
||||
[ "_$OUTPUT" = "_" ] || die "expected 'nvm_ensure_version_installed 0.1' to have no output, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm_ensure_version_installed 0.1' to exit with 0, got $EXIT_CODE"
|
||||
|
||||
# Special case for "iojs"
|
||||
OUTPUT="$(nvm_ensure_version_installed iojs 2>&1)"
|
||||
EXIT_CODE=$?
|
||||
EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed'
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed iojs' to give $EXPECTED_OUTPUT, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed iojs' to exit with 1, got $EXIT_CODE"
|
||||
|
||||
cleanup
|
12
test/fast/Unit tests/nvm_ensure_version_prefix
Executable file
12
test/fast/Unit tests/nvm_ensure_version_prefix
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "_$(nvm_ensure_version_prefix 1)" = "_v1" ] || die '"nvm_ensure_version_prefix 1" did not return "v1"'
|
||||
[ "_$(nvm_ensure_version_prefix v1)" = "_v1" ] || die '"nvm_ensure_version_prefix v1" did not return "v1"'
|
||||
[ "_$(nvm_ensure_version_prefix foo)" = "_foo" ] || die '"nvm_ensure_version_prefix foo" did not return "foo"'
|
||||
|
||||
[ "_$(nvm_ensure_version_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-1" did not return "iojs-v1"'
|
||||
[ "_$(nvm_ensure_version_prefix iojs-v1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-v1" did not return "iojs-v1"'
|
80
test/fast/Unit tests/nvm_get_arch
Executable file
80
test/fast/Unit tests/nvm_get_arch
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Save the PATH as it was when the test started to restore it when it
|
||||
# finishes
|
||||
ORIG_PATH=$PATH
|
||||
|
||||
cleanup() {
|
||||
# Restore the PATH as it was when the test started
|
||||
export PATH=ORIG_PATH
|
||||
}
|
||||
|
||||
die () { cleanup; echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
# Directory where mocked binaries used by nvm_get_arch for each OS/arch are
|
||||
# located
|
||||
MOCKS_DIR=`pwd`/../../mocks
|
||||
# Sets the PATH for these tests to include the symlinks to the mocked
|
||||
# binaries
|
||||
export PATH=.:${PATH}
|
||||
|
||||
# Setups mock binaries for a given OS and arch that mimic
|
||||
# the output of the real binaries used by nvm_get_arch to guess
|
||||
# the architecture of a given system.
|
||||
setup_mock_arch() {
|
||||
local OS=$1
|
||||
local ARCH=$2
|
||||
local OPT=$3
|
||||
|
||||
if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then
|
||||
ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo
|
||||
if [ "_$OPT" != "_no_pkg_info" ]; then
|
||||
ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info
|
||||
fi
|
||||
fi
|
||||
|
||||
ln -sf "${MOCKS_DIR}/uname_${OS}_${ARCH}" ./uname
|
||||
}
|
||||
|
||||
# Cleans up the setup done by setup_mock_arch.
|
||||
cleanup_mock_arch() {
|
||||
local OS=$1
|
||||
local ARCH=$2
|
||||
|
||||
if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then
|
||||
rm -f ./isainfo
|
||||
rm -f ./pkg_info
|
||||
fi
|
||||
|
||||
rm -f ./uname
|
||||
}
|
||||
|
||||
# Runs nvm_get_arch for architecture $ARCH and OS $OS, and compares the
|
||||
# expected output $EXPECTED_OUTPUT with the actual output. Does nothing
|
||||
# and exits cleanly if they match, dies otherwise.
|
||||
run_test() {
|
||||
local ARCH=$1
|
||||
local OS=$2
|
||||
local EXPECTED_OUTPUT=$3
|
||||
local OPT=$4
|
||||
|
||||
setup_mock_arch $OS $ARCH $OPT
|
||||
local OUTPUT="$(nvm_get_arch)"
|
||||
cleanup_mock_arch $OS $ARCH
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] ||
|
||||
die "nvm_get_arch for OS \"$OS\" and arch \"$ARCH\" with OPT \"$OPT\" did
|
||||
not return \"$EXPECTED_OUTPUT\"; got \"$OUTPUT\""
|
||||
}
|
||||
|
||||
run_test x86 smartos x86
|
||||
run_test x86 smartos x86 no_pkg_info
|
||||
|
||||
run_test amd64 smartos x64
|
||||
run_test amd64 smartos x64 no_pkg_info
|
||||
|
||||
run_test x86 osx x86
|
||||
run_test amd64 osx x64
|
||||
|
||||
cleanup
|
32
test/fast/Unit tests/nvm_has_solaris_binary
Executable file
32
test/fast/Unit tests/nvm_has_solaris_binary
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
# Invalid version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary ""
|
||||
assert_not_ok nvm_has_solaris_binary "foo"
|
||||
|
||||
# "Invalid" node version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary "v1.0.0"
|
||||
assert_not_ok nvm_has_solaris_binary "v3.3.1"
|
||||
|
||||
# Valid io.js version numbers that have a Solaris binary succeed
|
||||
assert_ok nvm_has_solaris_binary "iojs-v3.3.1"
|
||||
|
||||
# Invvalid io.js version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary "iojs-v0.12.7"
|
||||
|
||||
# Valid node version numbers that don't have a Solaris binary fail
|
||||
assert_not_ok nvm_has_solaris_binary "v0.8.5"
|
||||
|
||||
# Valid node version numbers that have a Solaris binary succeed
|
||||
assert_ok nvm_has_solaris_binary "v0.8.6"
|
||||
assert_ok nvm_has_solaris_binary "v0.10.0"
|
||||
assert_ok nvm_has_solaris_binary "v0.12.7"
|
||||
|
||||
# Valid "merged" version numbers succeed
|
||||
assert_ok nvm_has_solaris_binary "v4.0.0"
|
||||
assert_ok nvm_has_solaris_binary "v4.1.1"
|
31
test/fast/Unit tests/nvm_has_system_iojs
Executable file
31
test/fast/Unit tests/nvm_has_system_iojs
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
rm ../../../versions/io.js/v0.1.2/node
|
||||
rm ../../../versions/io.js/v0.1.2/iojs
|
||||
rmdir ../../../versions/io.js/v0.1.2
|
||||
}
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
mkdir ../../../versions/io.js/v0.1.2
|
||||
touch ../../../versions/io.js/v0.1.2/node
|
||||
touch ../../../versions/io.js/v0.1.2/iojs
|
||||
|
||||
nvm use iojs-v0.1.2
|
||||
|
||||
if command -v iojs; then
|
||||
nvm_has_system_iojs
|
||||
else
|
||||
! nvm_has_system_iojs
|
||||
fi
|
||||
|
||||
nvm deactivate /dev/null 2>&1
|
||||
|
||||
if command -v iojs; then
|
||||
nvm_has_system_iojs
|
||||
else
|
||||
! nvm_has_system_iojs
|
||||
fi
|
||||
|
7
test/fast/Unit tests/nvm_iojs_prefix
Executable file
7
test/fast/Unit tests/nvm_iojs_prefix
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "$(nvm_iojs_prefix)" = "iojs" ] || die '"nvm_iojs_prefix" did not return the string "iojs". why did this fail?!'
|
20
test/fast/Unit tests/nvm_is_alias
Executable file
20
test/fast/Unit tests/nvm_is_alias
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () { unalias foo; unalias grep; }
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
alias foo='bar'
|
||||
nvm_is_alias foo || die '"nvm_is_alias foo" was not true'
|
||||
|
||||
! nvm_is_alias nvm_is_alias || die '"nvm_is_alias nvm_is_alias was not false'
|
||||
|
||||
alias grep='grep'
|
||||
unalias grep || die '"unalias grep" failed'
|
||||
! nvm_is_alias grep || die '"nvm_is_alias grep" with unaliased grep was not false'
|
||||
|
||||
alias grep='grep'
|
||||
nvm_is_alias grep || die '"nvm_is_alias grep" with aliased grep was not true'
|
||||
|
||||
cleanup
|
10
test/fast/Unit tests/nvm_is_iojs_version
Executable file
10
test/fast/Unit tests/nvm_is_iojs_version
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm_is_iojs_version 'iojs-' || die '"nvm_is_iojs_version iojs- was not true'
|
||||
nvm_is_iojs_version 'iojs-foo' || die '"nvm_is_iojs_version iojs- was not true'
|
||||
! nvm_is_iojs_version 'iojs' || die '"nvm_is_iojs_version iojs was not false'
|
||||
! nvm_is_iojs_version 'v1.0.0' || die '"nvm_is_iojs_version v1.0.0" was not false'
|
10
test/fast/Unit tests/nvm_is_merged_node_version
Executable file
10
test/fast/Unit tests/nvm_is_merged_node_version
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm_is_merged_node_version '4.0' || die '"nvm_is_merged_node_version 4.0 was not true'
|
||||
nvm_is_merged_node_version '5.1' || die '"nvm_is_merged_node_version 5.1 was not true'
|
||||
! nvm_is_merged_node_version '3.99' || die '"nvm_is_merged_node_version 3.99 was not false'
|
||||
! nvm_is_merged_node_version 'v1.0.0' || die '"nvm_is_merged_node_version v1.0.0" was not false'
|
13
test/fast/Unit tests/nvm_is_valid_version
Executable file
13
test/fast/Unit tests/nvm_is_valid_version
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm_is_valid_version 0.1.2 || die "nvm_is_valid_version 0.1.2 did not return 0"
|
||||
nvm_is_valid_version foo && die "nvm_is_valid_version foo did not return 1"
|
||||
nvm_is_valid_version iojs-1 || die "nvm_is_valid_version iojs-1 did not return 0"
|
||||
nvm_is_valid_version iojs || die "nvm_is_valid_version iojs did not return 0"
|
||||
nvm_is_valid_version node || die "nvm_is_valid_version node did not return 0"
|
||||
nvm_is_valid_version stable || die "nvm_is_valid_version stable did not return 0"
|
||||
nvm_is_valid_version unstable || die "nvm_is_valid_version unstable did not return 0"
|
@@ -1,19 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
TEST_PWD=$(pwd)
|
||||
TEST_DIR="$TEST_PWD/nvm_ls_current_tmp"
|
||||
|
||||
cleanup() { rm -rf "$TEST_DIR"; unset -f return_zero; alias node='node' ; unalias node; }
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
return_zero () { return 0; }
|
||||
|
||||
[ "$(nvm deactivate > /dev/null 2>&1 ; nvm_ls_current)" = "system" ] || die 'when deactivated, did not return "system"'
|
||||
if nvm_has_system_node || nvm_has_system_iojs; then
|
||||
EXPECTED_SYSTEM_NODE="system"
|
||||
else
|
||||
EXPECTED_SYSTEM_NODE="none"
|
||||
fi
|
||||
[ "_$(nvm deactivate > /dev/null 2>&1 ; nvm_ls_current)" = "_$EXPECTED_SYSTEM_NODE" ] || die "when deactivated, did not return $EXPECTED_SYSTEM_NODE"
|
||||
|
||||
TEST_PWD=$(pwd)
|
||||
TEST_DIR="$TEST_PWD/nvm_ls_current_tmp"
|
||||
rm -rf "$TEST_DIR"
|
||||
mkdir "$TEST_DIR"
|
||||
ln -s "$(which which)" "$TEST_DIR/which"
|
||||
ln -s "$(which dirname)" "$TEST_DIR/dirname"
|
||||
ln -s "$(command which which)" "$TEST_DIR/which"
|
||||
ln -s "$(command which dirname)" "$TEST_DIR/dirname"
|
||||
|
||||
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"'
|
||||
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'
|
||||
@@ -24,5 +31,7 @@ chmod a+x "$TEST_DIR/node"
|
||||
|
||||
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version'
|
||||
|
||||
rm -rf "$TEST_DIR"
|
||||
alias node='node --harmony'
|
||||
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version'
|
||||
|
||||
cleanup
|
||||
|
34
test/fast/Unit tests/nvm_ls_remote_iojs
Executable file
34
test/fast/Unit tests/nvm_ls_remote_iojs
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
unset -f nvm_download
|
||||
}
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
# sample output at the time the test was written
|
||||
nvm_download() {
|
||||
echo 'version date files npm v8 uv zlib openssl modules'
|
||||
echo 'v1.0.1 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-tar,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi'
|
||||
echo 'v1.0.0 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-tar,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi'
|
||||
}
|
||||
|
||||
OUTPUT="$(nvm_ls_remote_iojs foo)"
|
||||
EXIT_CODE="$(nvm_ls_remote_iojs foo >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_ls_remote_iojs)"
|
||||
EXPECTED_OUTPUT="$(nvm_download | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | sed -e 's/^/iojs-/')"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote_iojs did not output expected sorted versions; got $(echo "$OUTPUT") expected $(echo "$EXPECTED_OUTPUT")"
|
||||
|
||||
OUTPUT="$(nvm_ls_remote_iojs 1.0)"
|
||||
EXPECTED_OUTPUT="iojs-v1.0.0
|
||||
iojs-v1.0.1"
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote_iojs 1.0 did not output 1.0.x versions; got $OUTPUT"
|
||||
|
||||
cleanup
|
||||
|
7
test/fast/Unit tests/nvm_node_prefix
Executable file
7
test/fast/Unit tests/nvm_node_prefix
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "$(nvm_node_prefix)" = "node" ] || die '"nvm_node_prefix" did not return the string "node". why did this fail?!'
|
@@ -5,13 +5,17 @@ die () { echo $@ ; exit 1; }
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0"
|
||||
[ "~$(nvm_num_version_groups v)" = "~0" ] || die "just "v" should give 0"
|
||||
[ "~$(nvm_num_version_groups .)" = "~0" ] || die "just "." should give 0"
|
||||
[ "~$(nvm_num_version_groups a)" = "~1" ] || die "one letter should give 1"
|
||||
|
||||
[ "~$(nvm_num_version_groups 1)" = "~1" ] || die "1 should give 1"
|
||||
[ "~$(nvm_num_version_groups 1.)" = "~1" ] || die "1. should give 1"
|
||||
[ "~$(nvm_num_version_groups v1)" = "~1" ] || die "v1 should give 1"
|
||||
[ "~$(nvm_num_version_groups v1.)" = "~1" ] || die "v1. should give 1"
|
||||
|
||||
[ "~$(nvm_num_version_groups 1.2)" = "~2" ] || die "1.2 should give 2"
|
||||
[ "~$(nvm_num_version_groups 1.2.)" = "~2" ] || die "1.2. should give 2"
|
||||
[ "~$(nvm_num_version_groups v1.2)" = "~2" ] || die "v1.2 should give 2"
|
||||
[ "~$(nvm_num_version_groups v1.2.)" = "~2" ] || die "v1.2. should give 2"
|
||||
|
||||
|
@@ -14,13 +14,13 @@ FIRST_EXIT_CODE="$(nvm_print_implicit_alias > /dev/null 2>&1 ; echo $?)"
|
||||
[ "_$FIRST_EXIT_CODE" = "_1" ] \
|
||||
|| die "nvm_print_implicit_alias without local|remote had wrong exit code: expected 1, got $FIRST_EXIT_CODE"
|
||||
|
||||
EXPECTED_SECOND_MSG="Only implicit aliases 'stable' and 'unstable' are supported."
|
||||
EXPECTED_SECOND_MSG="Only implicit aliases 'stable', 'unstable', 'iojs', and 'node' are supported."
|
||||
[ "_$(nvm_print_implicit_alias local 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|
||||
|| die "nvm_print_implicit_alias did not require stable|unstable as second argument"
|
||||
|| die "nvm_print_implicit_alias did not require stable|unstable|iojs|node as second argument"
|
||||
[ "_$(nvm_print_implicit_alias local foo 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|
||||
|| die "nvm_print_implicit_alias did not require stable|unstable as second argument"
|
||||
|| die "nvm_print_implicit_alias did not require stable|unstable|iojs|node as second argument"
|
||||
|
||||
SECOND_EXIT_CODE="$(nvm_print_implicit_alias local > /dev/null 2>&1 ; echo $?)"
|
||||
[ "_$SECOND_EXIT_CODE" = "_2" ] \
|
||||
|| die "nvm_print_implicit_alias without stable|unstable had wrong exit code: expected 2, got $SECOND_EXIT_CODE"
|
||||
|| die "nvm_print_implicit_alias without stable|unstable|iojs|node had wrong exit code: expected 2, got $SECOND_EXIT_CODE"
|
||||
|
||||
|
@@ -7,7 +7,10 @@ cleanup() {
|
||||
rm -rf ../../../v0.4.6
|
||||
rm -rf ../../../v0.5.7
|
||||
rm -rf ../../../v0.7.7
|
||||
unset -f nvm_ls_remote
|
||||
rm -rf ../../../versions/io.js/v0.98.0
|
||||
rm -rf ../../../versions/node/v1.0.0
|
||||
rm -rf ../../../versions/node/v1.1.0
|
||||
unset -f nvm_ls_remote nvm_ls_remote_iojs
|
||||
}
|
||||
|
||||
. ../../../nvm.sh
|
||||
@@ -17,13 +20,31 @@ mkdir ../../../v0.3.4
|
||||
mkdir ../../../v0.4.6
|
||||
mkdir ../../../v0.5.7
|
||||
mkdir ../../../v0.7.7
|
||||
mkdir -p ../../../versions/io.js/v0.98.0
|
||||
|
||||
LATEST_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
[ "_$LATEST_STABLE" = "_0.4" ] || die "local stable is not latest even minor: expected 0.4, got $LATEST_STABLE"
|
||||
|
||||
LATEST_NODE="$(nvm_print_implicit_alias local node)"
|
||||
[ "_$LATEST_NODE" = "_stable" ] || die "local node is not stable: expected stable, got $LATEST_NODE"
|
||||
|
||||
LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest odd minor: expected 0.7, got $LATEST_UNSTABLE"
|
||||
|
||||
LATEST_IOJS="$(nvm_print_implicit_alias local iojs)"
|
||||
[ "_$LATEST_IOJS" = "_iojs-v0.98" ] || die "local iojs is not latest iojs: expected iojs-v0.98, got $LATEST_IOJS"
|
||||
|
||||
## node post v1.0/io.js merger ##
|
||||
mkdir -p ../../../versions/node/v1.0.0
|
||||
mkdir -p ../../../versions/node/v1.1.0
|
||||
|
||||
LATEST_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
[ "_$LATEST_STABLE" = "_1.1" ] || die "local stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE"
|
||||
|
||||
LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest pre-v1.0 odd minor: expected 0.7, got $LATEST_UNSTABLE"
|
||||
## ** ##
|
||||
|
||||
nvm_ls_remote() {
|
||||
echo "v0.4.3"
|
||||
echo "v0.5.4"
|
||||
@@ -37,11 +58,48 @@ nvm_ls_remote() {
|
||||
echo "v0.9.7"
|
||||
}
|
||||
|
||||
nvm_ls_remote_iojs() {
|
||||
echo "iojs-v0.1.0"
|
||||
echo "iojs-v0.1.1"
|
||||
echo "iojs-v0.7.8"
|
||||
echo "iojs-v0.98.5"
|
||||
echo "iojs-v0.99.0"
|
||||
}
|
||||
|
||||
LATEST_STABLE="$(nvm_print_implicit_alias remote stable)"
|
||||
[ "_$LATEST_STABLE" = "_0.6" ] || die "remote stable is not latest even minor: expected 0.6, got $LATEST_STABLE"
|
||||
|
||||
LATEST_NODE="$(nvm_print_implicit_alias remote node)"
|
||||
[ "_$LATEST_NODE" = "_stable" ] || die "remote node is not stable: expected stable, got $LATEST_NODE"
|
||||
|
||||
LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
|
||||
[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd minor: expected 0.9, got $LATEST_UNSTABLE"
|
||||
|
||||
LATEST_IOJS="$(nvm_print_implicit_alias remote iojs)"
|
||||
[ "_$LATEST_IOJS" = "_iojs-v0.99" ] || die "remote iojs is not latest: expected iojs-v0.99, got $LATEST_IOJS"
|
||||
|
||||
## node post v1.0/io.js merger ##
|
||||
nvm_ls_remote() {
|
||||
echo "v0.4.3"
|
||||
echo "v0.5.4"
|
||||
echo "v0.6.6"
|
||||
echo "v0.7.7"
|
||||
echo "v0.9.7"
|
||||
echo "v0.4.3"
|
||||
echo "v0.5.4"
|
||||
echo "v0.6.6"
|
||||
echo "v0.7.7"
|
||||
echo "v0.9.7"
|
||||
echo "v1.0.0"
|
||||
echo "v1.1.0"
|
||||
}
|
||||
|
||||
LATEST_STABLE="$(nvm_print_implicit_alias remote stable)"
|
||||
[ "_$LATEST_STABLE" = "_1.1" ] || die "remote stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE"
|
||||
|
||||
LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
|
||||
[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd pre-v1.0 minor: expected 0.9, got $LATEST_UNSTABLE"
|
||||
## ** ##
|
||||
|
||||
cleanup
|
||||
|
||||
|
28
test/fast/Unit tests/nvm_print_npm_version
Executable file
28
test/fast/Unit tests/nvm_print_npm_version
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
alias nvm_has='\nvm_has'
|
||||
alias npm='\npm'
|
||||
unset -f nvm_has npm
|
||||
}
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm_has() { return 1; }
|
||||
OUTPUT="$(nvm_print_npm_version)"
|
||||
[ -z "$OUTPUT" ] || die "nvm_print_npm_version did not return empty when nvm_has returns 1, got '$OUTPUT'"
|
||||
|
||||
nvm_has() { return 0; }
|
||||
npm() {
|
||||
if [ "_$@" = "_--version" ]; then
|
||||
echo "1.2.3"
|
||||
else
|
||||
echo "error"
|
||||
fi
|
||||
}
|
||||
OUTPUT="$(nvm_print_npm_version)"
|
||||
EXPECTED_OUTPUT=" (npm v1.2.3)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_npm_version did not provided '$EXPECTED_OUTPUT', got '$OUTPUT'"
|
||||
|
||||
cleanup
|
@@ -3,7 +3,7 @@
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
unset -f nvm_ls_remote
|
||||
unset -f nvm_ls_remote nvm_ls_remote_iojs
|
||||
}
|
||||
|
||||
. ../../../nvm.sh
|
||||
@@ -11,25 +11,68 @@ cleanup() {
|
||||
nvm_ls_remote() {
|
||||
echo "N/A"
|
||||
}
|
||||
|
||||
OUTPUT="$(nvm_remote_version foo)"
|
||||
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|
||||
|
||||
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
|
||||
|
||||
nvm_ls_remote() {
|
||||
echo "test output"
|
||||
echo "more test output"
|
||||
echo "pattern received: _$1_"
|
||||
nvm_ls_remote_iojs() {
|
||||
echo "N/A"
|
||||
}
|
||||
OUTPUT="$(nvm_remote_version iojs-foo)"
|
||||
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
|
||||
|
||||
|
||||
nvm_ls_remote() {
|
||||
if ! nvm_is_iojs_version "$1"; then
|
||||
echo "test output"
|
||||
echo "more test output"
|
||||
echo "pattern received: _$1_"
|
||||
fi
|
||||
}
|
||||
nvm_ls_remote_iojs() {
|
||||
if [ -z "$1" ] || nvm_is_iojs_version "$1"; then
|
||||
echo "test iojs output"
|
||||
echo "more iojs test output"
|
||||
echo "iojs pattern received: _$1_"
|
||||
fi
|
||||
}
|
||||
OUTPUT="$(nvm_remote_version foo)"
|
||||
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|
||||
|
||||
[ "_$OUTPUT" = "_pattern received: _foo_" ] \
|
||||
|| die "nvm_remote_version foo did not return last line only of nvm_ls_remote foo; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version foo did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
cleanup
|
||||
OUTPUT="$(nvm_remote_version iojs-foo)"
|
||||
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_iojs pattern received: _iojs-foo_" ] \
|
||||
|| die "nvm_remote_version iojs-foo did not return last line only of nvm_ls_remote_iojs foo; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_remote_version iojs)"
|
||||
EXIT_CODE="$(nvm_remote_version iojs >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_iojs pattern received: __" ] \
|
||||
|| die "nvm_remote_version iojs did not return last line only of nvm_ls_remote_iojs; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_remote_version stable)"
|
||||
EXIT_CODE="$(nvm_remote_version stable >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$(nvm_ls_remote stable)" ] \
|
||||
|| die "nvm_remote_version stable did not return contents of nvm_ls_remote stable; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version stable did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_remote_version unstable)"
|
||||
EXIT_CODE="$(nvm_remote_version unstable >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$(nvm_ls_remote unstable)" ] \
|
||||
|| die "nvm_remote_version unstable did not return contents of nvm_ls_remote unstable; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version unstable did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_remote_version node)"
|
||||
EXIT_CODE="$(nvm_remote_version node >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$(nvm_ls_remote node)" ] \
|
||||
|| die "nvm_remote_version node did not return contents of nvm_ls_remote node; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version node did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
cleanup
|
||||
|
78
test/fast/Unit tests/nvm_remote_versions
Executable file
78
test/fast/Unit tests/nvm_remote_versions
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
unset -f nvm_ls_remote nvm_ls_remote_iojs
|
||||
}
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
OUTPUT="$(nvm_remote_versions stable 2>&1)"
|
||||
EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions."
|
||||
EXIT_CODE="$(nvm_remote_versions stable >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'stable' did not error out with correct message, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'stable' did not exit with code 1, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_remote_versions unstable 2>&1)"
|
||||
EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions."
|
||||
EXIT_CODE="$(nvm_remote_versions unstable >/dev/null 2>&1; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'unstable' did not error out with correct message, got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'unstable' did not exit with code 1, got $EXIT_CODE"
|
||||
|
||||
nvm_ls_remote() {
|
||||
echo "N/A"
|
||||
}
|
||||
OUTPUT="$(nvm_remote_versions foo)"
|
||||
EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
|
||||
|
||||
nvm_ls_remote_iojs() {
|
||||
echo "N/A"
|
||||
}
|
||||
OUTPUT="$(nvm_remote_versions iojs-foo)"
|
||||
EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
|
||||
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
|
||||
|
||||
|
||||
nvm_ls_remote() {
|
||||
echo "test output"
|
||||
echo "more test output"
|
||||
echo "pattern received: _$1_"
|
||||
}
|
||||
nvm_ls_remote_iojs() {
|
||||
echo "test iojs output"
|
||||
echo "more iojs test output"
|
||||
echo "iojs pattern received: _$1_"
|
||||
}
|
||||
|
||||
OUTPUT="$(nvm_remote_versions foo)"
|
||||
EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$(nvm_ls_remote foo)
|
||||
$(nvm_ls_remote_iojs foo)" ] \
|
||||
|| die "nvm_remote_versions foo did not return contents of nvm_ls_remote foo combined with nvm_ls_remote_iojs foo; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions foo did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_remote_versions node)"
|
||||
EXIT_CODE="$(nvm_remote_versions node >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$(nvm_ls_remote)" ] \
|
||||
|| die "nvm_remote_versions node did not return contents of nvm_ls_remote; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions node did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_remote_versions iojs-foo)"
|
||||
EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$(nvm_ls_remote iojs-foo)
|
||||
$(nvm_ls_remote_iojs iojs-foo)" ] \
|
||||
|| die "nvm_remote_versions iojs-foo did not return contents of nvm_ls_remote iojs-foo combined with nvm_ls_remote_iojs iojs-foo; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs-foo did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
OUTPUT="$(nvm_remote_versions iojs)"
|
||||
EXIT_CODE="$(nvm_remote_versions iojs >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$(nvm_ls_remote_iojs)" ] \
|
||||
|| die "nvm_remote_versions iojs did not return contents of nvm_ls_remote_iojs; got $OUTPUT"
|
||||
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs did not exit with 0, got $EXIT_CODE"
|
||||
|
||||
cleanup
|
||||
|
10
test/fast/Unit tests/nvm_strip_iojs_prefix
Executable file
10
test/fast/Unit tests/nvm_strip_iojs_prefix
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "_$(nvm_strip_iojs_prefix iojs)" = "_" ] || die '"nvm_strip_iojs_prefix iojs" did not return an empty string'
|
||||
[ "_$(nvm_strip_iojs_prefix iojs-)" = "_" ] || die '"nvm_strip_iojs_prefix iojs-" did not return an empty string'
|
||||
[ "_$(nvm_strip_iojs_prefix iojs-foo)" = "_foo" ] || die '"nvm_strip_iojs_prefix iojs-foo" did not return "foo"'
|
||||
[ "_$(nvm_strip_iojs_prefix iojsfoo)" = "_iojsfoo" ] || die '"nvm_strip_iojs_prefix iojsfoo" did not return "iojsfoo"'
|
@@ -4,7 +4,7 @@ die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
TEST_PATH=$NVM_DIR/v0.10.5/bin:/usr/bin:$NVM_DIR/v0.11.5/bin:$NVM_DIR/v0.9.5/bin:/usr/local/bin:$NVM_DIR/v0.2.5/bin
|
||||
TEST_PATH=$NVM_DIR/v0.10.5/bin:/usr/bin:$NVM_DIR/v0.11.5/bin:$NVM_DIR/v0.9.5/bin:/usr/local/bin:$NVM_DIR/v0.2.5/bin:$NVM_DIR/versions/node/v0.12.0/bin:$NVM_DIR/versions/io.js/v1.0.0/bin
|
||||
|
||||
STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"`
|
||||
|
||||
|
@@ -4,16 +4,18 @@ die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
EXPECTED_MSG="Only implicit aliases 'stable' and 'unstable' are supported."
|
||||
EXPECTED_MSG="Only implicit aliases 'stable', 'unstable', 'iojs', and 'node' are supported."
|
||||
[ "_$(nvm_validate_implicit_alias 2>&1)" = "_$EXPECTED_MSG" ] \
|
||||
|| die "nvm_validate_implicit_alias did not require stable|unstable"
|
||||
|| die "nvm_validate_implicit_alias did not require stable|unstable|iojs|node"
|
||||
[ "_$(nvm_validate_implicit_alias foo 2>&1)" = "_$EXPECTED_MSG" ] \
|
||||
|| die "nvm_validate_implicit_alias did not require stable|unstable"
|
||||
|| die "nvm_validate_implicit_alias did not require stable|unstable|iojs|node"
|
||||
|
||||
EXIT_CODE="$(nvm_validate_implicit_alias >/dev/null 2>&1 ; echo $?)"
|
||||
[ "_$EXIT_CODE" = "_1" ] \
|
||||
|| die "nvm_validate_implicit_alias without stable|unstable had wrong exit code: expected 1, got $EXIT_CODE"
|
||||
|| die "nvm_validate_implicit_alias without stable|unstable|iojs|node had wrong exit code: expected 1, got $EXIT_CODE"
|
||||
|
||||
nvm_validate_implicit_alias stable || die "nvm_validate_implicit_alias stable did not exit 0"
|
||||
nvm_validate_implicit_alias unstable || die "nvm_validate_implicit_alias unstable did not exit 0"
|
||||
nvm_validate_implicit_alias node || die "nvm_validate_implicit_alias node did not exit 0"
|
||||
nvm_validate_implicit_alias iojs || die "nvm_validate_implicit_alias iojs did not exit 0"
|
||||
|
||||
|
48
test/fast/Unit tests/nvm_version
Executable file
48
test/fast/Unit tests/nvm_version
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
cleanup () {
|
||||
unset -f nvm_ls_current nvm_ls
|
||||
}
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm_ls_current() {
|
||||
echo "CURRENT!"
|
||||
return 7
|
||||
}
|
||||
|
||||
OUTPUT="$(nvm_version current)"
|
||||
EXPECTED_OUTPUT="CURRENT!"
|
||||
EXIT_CODE="$(nvm_version current 2>&1 >/dev/null ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version current" did not return nvm_ls_current output'
|
||||
[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version current" did not return nvm_ls_current exit code'
|
||||
|
||||
OUTPUT="$(nvm_version)"
|
||||
EXPECTED_OUTPUT="CURRENT!"
|
||||
EXIT_CODE="$(nvm_version 2>&1 >/dev/null ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return nvm_ls_current output'
|
||||
[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version" did not return nvm_ls_current exit code'
|
||||
|
||||
nvm_ls() {
|
||||
echo "line 1"
|
||||
echo "line 2"
|
||||
echo "pattern: $1"
|
||||
}
|
||||
[ "_$(nvm_version foo)" = "_pattern: foo" ] || die '"nvm_version foo" did not pass the pattern to "nvm_ls", or return the last line'
|
||||
[ "_$(nvm_version node)" = "_pattern: stable" ] || die '"nvm_version node" did not pass "stable" to "nvm_ls"'
|
||||
[ "_$(nvm_version node-)" = "_pattern: stable" ] || die '"nvm_version node-" did not pass "stable" to "nvm_ls"'
|
||||
|
||||
nvm_ls() { echo "N/A"; }
|
||||
OUTPUT="$(nvm_version foo)"
|
||||
EXPECTED_OUTPUT="N/A"
|
||||
EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns N/A'
|
||||
[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3'
|
||||
|
||||
nvm_ls() { echo; }
|
||||
OUTPUT="$(nvm_version foo)"
|
||||
EXPECTED_OUTPUT="N/A"
|
||||
EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)"
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns nothing'
|
||||
[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3'
|
@@ -4,7 +4,8 @@ die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "$(nvm_version_dir)" = "$NVM_DIR/versions" ] || die '"nvm_version_dir" did not return new dir path'
|
||||
[ "$(nvm_version_dir)" = "$NVM_DIR/versions/node" ] || die '"nvm_version_dir" did not return new dir path'
|
||||
[ "$(nvm_version_dir iojs)" = "$NVM_DIR/versions/io.js" ] || die '"nvm_version_dir iojs" did not return iojs dir path'
|
||||
[ "$(nvm_version_dir new)" = "$(nvm_version_dir)" ] || die '"nvm_version_dir new" did not return new dir path'
|
||||
[ "$(nvm_version_dir old)" = "$NVM_DIR" ] || die '"nvm_version_dir old" did not return old dir path'
|
||||
[ "$(nvm_version_dir foo 2>&1)" = "unknown version dir" ] || die '"nvm_version_dir foo" did not error out'
|
||||
|
@@ -7,5 +7,6 @@ die () { echo $@ ; exit 1; }
|
||||
[ "$(nvm_version_path foo)" = "$NVM_DIR/foo" ] || die '"nvm_version_path foo" did not return correct location'
|
||||
[ "$(nvm_version_path 2>&1)" = "version is required" ] || die '"nvm_version_path" did not error out'
|
||||
[ "$(nvm_version_path v0.11.0)" = "$NVM_DIR/v0.11.0" ] || die 'old version has the wrong path'
|
||||
[ "$(nvm_version_path v0.12.0)" = "$NVM_DIR/versions/v0.12.0" ] || die 'new version has the wrong path'
|
||||
[ "$(nvm_version_path v0.12.0)" = "$NVM_DIR/versions/node/v0.12.0" ] || die 'new version has the wrong path'
|
||||
[ "$(nvm_version_path iojs-v0.12.0)" = "$NVM_DIR/versions/io.js/v0.12.0" ] || die 'iojs version has the wrong path'
|
||||
|
||||
|
54
test/install_script/nvm_check_global_modules
Executable file
54
test/install_script/nvm_check_global_modules
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
rm -rf "$npm_config_prefix/lib" >/dev/null 2>&1
|
||||
unset npm_config_prefix
|
||||
|
||||
rm -f npm
|
||||
PATH="$ORIGINAL_PATH"
|
||||
|
||||
unset -f setup cleanup die
|
||||
unset message ORIGINAL_PATH
|
||||
}
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
|
||||
NVM_ENV=testing . ../../install.sh
|
||||
|
||||
setup () {
|
||||
ORIGINAL_PATH="$PATH"
|
||||
|
||||
npm_config_prefix="$(pwd)"
|
||||
export npm_config_prefix
|
||||
mkdir -p "$npm_config_prefix/lib"
|
||||
}
|
||||
|
||||
|
||||
setup
|
||||
|
||||
npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package'
|
||||
message=$(nvm_check_global_modules)
|
||||
[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed"
|
||||
|
||||
npm uninstall -g nop >/dev/null
|
||||
message=$(nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed"
|
||||
|
||||
# Faking an installation of npm
|
||||
mkdir -p "$npm_config_prefix/lib/node_modules/npm"
|
||||
cat <<'JSON' >"$npm_config_prefix/lib/node_modules/npm/package.json"
|
||||
{ "name": "npm", "version": "0.0.1fake" }
|
||||
JSON
|
||||
|
||||
message=$(nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm had only itself installed as a global module"
|
||||
|
||||
# Faking the absence of npm
|
||||
PATH=".:$PATH"
|
||||
touch npm
|
||||
chmod +x npm
|
||||
|
||||
message=$(nvm_check_global_modules)
|
||||
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm was unavailable"
|
||||
|
||||
|
||||
cleanup
|
@@ -22,46 +22,80 @@ HOME="."
|
||||
|
||||
setup
|
||||
|
||||
#Let's force $SHELL to be bash
|
||||
SHELL="/bin/bash"
|
||||
|
||||
# $SHELL is set to bash and .bashrc is there, it must be detected
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" = "_$HOME/.bashrc" ] || echo "_\$HOME/.bashrc: _$HOME/.bashrc\n" \
|
||||
echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
die "nvm_detect_profile didn't pick $SHELL and $HOME/.bashrc"
|
||||
|
||||
#Let's force $SHELL to be zsh
|
||||
SHELL="/usr/bin/zsh"
|
||||
|
||||
# $SHELL is set to zsh and .zshrc is there, it must be detected
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" = "_$HOME/.zshrc" ] || echo "_\$HOME/.zshrc: _$HOME/.zshrc\n" \
|
||||
echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
die "nvm_detect_profile didn't pick $SHELL and $HOME/.zshrc"
|
||||
|
||||
|
||||
# if we unset shell it looks for the files
|
||||
unset SHELL
|
||||
|
||||
# $PROFILE points to a valid file, its path must be returned
|
||||
PROFILE="test_profile"
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" = "_$PROFILE" ] || die "nvm_detect_profile didn't pick \$PROFILE"
|
||||
[ "_$_PROFILE" = "_$PROFILE" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
echo "_\$PROFILE: _$PROFILE\n" \
|
||||
die "nvm_detect_profile didn't pick \$PROFILE"
|
||||
|
||||
# $PROFILE doesn't point to a valid file, its path must not be returned
|
||||
PROFILE="invalid_profile"
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" != "_$PROFILE" ] || die "nvm_detect_profile shouldn't pick \$PROFILE when it's not a valid file"
|
||||
[ "_$_PROFILE" != "_$PROFILE" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
echo "_\$PROFILE: _$PROFILE\n" \
|
||||
die "nvm_detect_profile shouldn't pick \$PROFILE when it's not a valid file"
|
||||
|
||||
|
||||
# Below are tests for when $PROFILE is undefined
|
||||
rm test_profile
|
||||
unset PROFILE
|
||||
|
||||
# It should favor .bashrc if file exists
|
||||
# It should favor .profile if file exists
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" = "_$HOME/.bashrc" ] || die "nvm_detect_profile should have selected .bashrc"
|
||||
[ "_$_PROFILE" = "_$HOME/.profile" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
echo "_\$PROFILE: _$PROFILE\n" \
|
||||
die "nvm_detect_profile should have selected .profile"
|
||||
|
||||
rm .profile
|
||||
# Otherwise, it should favor .bashrc if file exists
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" = "_$HOME/.bashrc" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
echo "_\$PROFILE: _$PROFILE\n" \
|
||||
die "nvm_detect_profile should have selected .bashrc"
|
||||
|
||||
rm .bashrc
|
||||
# Otherwise, it should favor .bash_profile if file exists
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" = "_$HOME/.bash_profile" ] || die "nvm_detect_profile should have selected .bash_profile"
|
||||
[ "_$_PROFILE" = "_$HOME/.bash_profile" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
echo "_\$PROFILE: _$PROFILE\n" \
|
||||
die "nvm_detect_profile should have selected .bash_profile"
|
||||
|
||||
rm .bash_profile
|
||||
# Otherwise, it should favor .zshrc if file exists
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" = "_$HOME/.zshrc" ] || die "nvm_detect_profile should have selected .zshrc"
|
||||
[ "_$_PROFILE" = "_$HOME/.zshrc" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
echo "_\$PROFILE: _$PROFILE\n" \
|
||||
die "nvm_detect_profile should have selected .zshrc"
|
||||
|
||||
rm .zshrc
|
||||
# Otherwise, it should favor .profile if file exists
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ "_$_PROFILE" = "_$HOME/.profile" ] || die "nvm_detect_profile should have selected .profile"
|
||||
|
||||
rm .profile
|
||||
# It should be empty if none is found
|
||||
_PROFILE=$(nvm_detect_profile)
|
||||
[ -z "$_PROFILE" ] || die "nvm_detect_profile should have echo'ed an empty value"
|
||||
[ -z "$_PROFILE" ] || echo "_\$_PROFILE: _$_PROFILE\n" \
|
||||
echo "_\$PROFILE: _$PROFILE\n" \
|
||||
die "nvm_detect_profile should have echo'ed an empty value"
|
||||
|
||||
|
||||
cleanup
|
||||
|
||||
|
@@ -15,7 +15,7 @@ safe_type() {
|
||||
safe_type nvm_reset || die 'nvm_reset is not available'
|
||||
|
||||
# Apply nvm_reset
|
||||
nvm_reset
|
||||
nvm_reset || die 'nvm_reset failed'
|
||||
|
||||
# The names should be unset
|
||||
! safe_type nvm_do_install || die 'nvm_do_install is still available'
|
||||
|
26
test/installation/io.js/install already installed uses it
Executable file
26
test/installation/io.js/install already installed uses it
Executable file
@@ -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)"
|
||||
|
19
test/installation/io.js/install from binary
Executable file
19
test/installation/io.js/install from binary
Executable file
@@ -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"
|
||||
|
26
test/installation/io.js/install two versions and use the latest one
Executable file
26
test/installation/io.js/install two versions and use the latest one
Executable file
@@ -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)"
|
||||
|
24
test/installation/io.js/install version specified in .nvmrc from binary
Executable file
24
test/installation/io.js/install version specified in .nvmrc from binary
Executable file
@@ -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"
|
||||
|
||||
|
32
test/installation/io.js/install while reinstalling packages
Executable file
32
test/installation/io.js/install while reinstalling packages
Executable file
@@ -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 object-is@0.0.0 || die "npm install -g object-is failed"
|
||||
npm list --global | grep object-is > /dev/null || die "object-is 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 object-is > /dev/null || die "object-is isn't installed"
|
||||
|
20
test/installation/io.js/nvm install v1 works
Executable file
20
test/installation/io.js/nvm install v1 works
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_VERSION="v1"
|
||||
NVM_PREFIXED_TEST_VERSION="$(nvm ls-remote "$NVM_VERSION" | tail -n1 | sed 's/^[ ]*//;s/[ ]*$//')"
|
||||
NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")"
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Install from binary
|
||||
nvm install "$NVM_VERSION" || die "nvm install $NVM_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"
|
||||
|
14
test/installation/io.js/teardown_dir
Executable file
14
test/installation/io.js/teardown_dir
Executable file
@@ -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
|
||||
|
@@ -2,13 +2,13 @@
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../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 ../../v0.9.7 ] && rm -R ../../v0.9.7
|
||||
[ -e ../../v0.9.12 ] && rm -R ../../v0.9.12
|
||||
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
|
||||
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
|
||||
|
||||
# Install from binary
|
||||
nvm install 0.9.7
|
@@ -2,17 +2,17 @@
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_TEST_VERSION=v0.10.7
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Install from binary
|
||||
nvm install $NVM_TEST_VERSION || die "install $NVM_TEST_VERSION failed"
|
||||
|
||||
# Check
|
||||
[ -d ../../$NVM_TEST_VERSION ]
|
||||
[ -d ../../../$NVM_TEST_VERSION ]
|
||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||
|
@@ -2,17 +2,17 @@
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_TEST_VERSION=v0.10.7
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Install from source
|
||||
nvm install -s $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed"
|
||||
|
||||
# Check
|
||||
[ -d ../../$NVM_TEST_VERSION ]
|
||||
[ -d ../../../$NVM_TEST_VERSION ]
|
||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||
|
18
test/installation/node/install from source implicitly
Executable file
18
test/installation/node/install from source implicitly
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_TEST_VERSION=v0.8.5
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Install from source implicitly (v0.8.6 is when binaries started)
|
||||
nvm install $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed"
|
||||
|
||||
# Check
|
||||
[ -d ../../../$NVM_TEST_VERSION ]
|
||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||
|
25
test/installation/node/install from source without V8 snapshot for ARM
Executable file
25
test/installation/node/install from source without V8 snapshot for ARM
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_TEST_VERSION=v0.10.7
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Fake ARM arch
|
||||
nvm_get_arch() {
|
||||
echo "armv7l"
|
||||
}
|
||||
|
||||
# Install from source
|
||||
nvm install -s $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed"
|
||||
|
||||
# Check Install
|
||||
[ -d ../../../$NVM_TEST_VERSION ]
|
||||
node --version | grep $NVM_TEST_VERSION || "'node --version | grep $NVM_TEST_VERSION' failed"
|
||||
|
||||
# Check V8 snapshot isn't compiled
|
||||
node -p "if(! process.config.variables.v8_use_snapshot) { console.log('no-snapshot'); }" | grep "no-snapshot" || "'node -p \"if(! process.config.variables.v8_use_snapshot) { console.log('no-snapshot'); }\" | grep \"no-snapshot\"' failed"
|
@@ -2,19 +2,19 @@
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../v0.9.7 ] && rm -R ../../v0.9.7
|
||||
[ -e ../../v0.9.12 ] && rm -R ../../v0.9.12
|
||||
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
|
||||
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
|
||||
|
||||
# Install from binary
|
||||
nvm install 0.9.7 || die "'nvm install 0.9.7' failed"
|
||||
nvm i 0.9.12 || die "'nvm i 0.9.12' failed"
|
||||
|
||||
# Check
|
||||
[ -d ../../v0.9.7 ] || die "v0.9.7 didn't exist"
|
||||
[ -d ../../v0.9.12 ] || die "v0.9.12 didn't exist"
|
||||
[ -d ../../../v0.9.7 ] || die "v0.9.7 didn't exist"
|
||||
[ -d ../../../v0.9.12 ] || die "v0.9.12 didn't exist"
|
||||
|
||||
# Use the first one
|
||||
nvm use 0.9.7 || die "'nvm use 0.9.7' failed"
|
@@ -2,12 +2,12 @@
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_TEST_VERSION=v0.10.7
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Install from binary
|
||||
echo "$NVM_TEST_VERSION" > .nvmrc
|
||||
@@ -15,7 +15,7 @@ echo "$NVM_TEST_VERSION" > .nvmrc
|
||||
nvm install || die "'nvm install' failed"
|
||||
|
||||
# Check
|
||||
[ -d ../../$NVM_TEST_VERSION ] || die "./$NVM_TEST_VERSION did not exist"
|
||||
[ -d ../../../$NVM_TEST_VERSION ] || die "./$NVM_TEST_VERSION did not exist"
|
||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION \
|
||||
|| "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||
|
@@ -2,12 +2,12 @@
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
NVM_TEST_VERSION=v0.10.7
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||
|
||||
# Install from binary
|
||||
echo "$NVM_TEST_VERSION" > .nvmrc
|
||||
@@ -15,7 +15,7 @@ echo "$NVM_TEST_VERSION" > .nvmrc
|
||||
nvm install -s || "'nvm install -s' failed"
|
||||
|
||||
# Check
|
||||
[ -d ../../$NVM_TEST_VERSION ] || die "$NVM_TEST_VERSION did not exist"
|
||||
[ -d ../../../$NVM_TEST_VERSION ] || die "$NVM_TEST_VERSION did not exist"
|
||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION \
|
||||
|| die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||
|
@@ -2,33 +2,33 @@
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
|
||||
# Remove the stuff we're clobbering.
|
||||
[ -e ../../v0.9.7 ] && rm -R ../../v0.9.7
|
||||
[ -e ../../v0.9.12 ] && rm -R ../../v0.9.12
|
||||
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
|
||||
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
|
||||
|
||||
# Install from binary
|
||||
nvm install 0.9.7
|
||||
|
||||
# Check
|
||||
[ -d ../../v0.9.7 ] || die "nvm install 0.9.7 didn't install"
|
||||
[ -d ../../../v0.9.7 ] || die "nvm install 0.9.7 didn't install"
|
||||
|
||||
nvm use 0.9.7
|
||||
|
||||
node --version | grep v0.9.7 > /dev/null || die "nvm use 0.9.7 failed"
|
||||
|
||||
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"
|
||||
npm install -g object-is@0.0.0 || die "npm install -g object-is failed"
|
||||
npm list --global | grep object-is > /dev/null || die "object-is 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 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"
|
||||
|
||||
nvm use 0.9
|
||||
node --version | grep v0.9.12 > /dev/null || die "nvm ls 0.9 didn't use v0.9.12"
|
||||
|
||||
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||
npm list --global | grep object-is > /dev/null || die "object-is isn't installed"
|
||||
|
6
test/installation/node/setup_dir
Executable file
6
test/installation/node/setup_dir
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f ".nvmrc" ]; then
|
||||
mv .nvmrc .nvmrc.bak
|
||||
fi
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../nvm.sh
|
||||
. ../../../nvm.sh
|
||||
nvm deactivate
|
||||
nvm uninstall v0.10.7
|
||||
|
5
test/mocks/isainfo_amd64
Executable file
5
test/mocks/isainfo_amd64
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-n" ]; then
|
||||
echo "amd64"
|
||||
else
|
||||
echo "amd64 i386"
|
||||
fi
|
5
test/mocks/isainfo_x86
Executable file
5
test/mocks/isainfo_x86
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-n" ]; then
|
||||
echo "i386"
|
||||
else
|
||||
echo "i386"
|
||||
fi
|
1
test/mocks/pkg_info_amd64
Executable file
1
test/mocks/pkg_info_amd64
Executable file
@@ -0,0 +1 @@
|
||||
echo "x86_64"
|
1
test/mocks/pkg_info_x86
Executable file
1
test/mocks/pkg_info_x86
Executable file
@@ -0,0 +1 @@
|
||||
echo "i386"
|
5
test/mocks/uname_osx_amd64
Executable file
5
test/mocks/uname_osx_amd64
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-m" ]; then
|
||||
echo "x86_64"
|
||||
else
|
||||
echo "Darwin foo.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64"
|
||||
fi
|
5
test/mocks/uname_osx_x86
Executable file
5
test/mocks/uname_osx_x86
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-m" ]; then
|
||||
echo "i386"
|
||||
else
|
||||
echo "Darwin foo.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_I386 i386"
|
||||
fi
|
5
test/mocks/uname_smartos_amd64
Executable file
5
test/mocks/uname_smartos_amd64
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-m" ]; then
|
||||
echo "i86pc"
|
||||
else
|
||||
echo "SunOS dev 5.11 joyent_20150219T102159Z i86pc i386 i86pc Solaris"
|
||||
fi
|
5
test/mocks/uname_smartos_x86
Executable file
5
test/mocks/uname_smartos_x86
Executable file
@@ -0,0 +1,5 @@
|
||||
if [ "_$1" = "_-m" ]; then
|
||||
echo "i86pc"
|
||||
else
|
||||
echo "SunOS dev 5.11 joyent_20150219T102159Z i86pc i386 i86pc Solaris"
|
||||
fi
|
@@ -7,8 +7,3 @@ die () { echo $@ ; exit 1; }
|
||||
nvm install 0.10
|
||||
|
||||
[ "$(nvm current)" = "$(node -v)" ] || die "Failed to find current version: got \"$(nvm current)\", expected \"$(node -v)\""
|
||||
|
||||
nvm install 0.6.21
|
||||
[ "$(node -v)" = "v0.6.21-pre" ] || die "v0.6.21-pre not installed with v0.6.21"
|
||||
[ "$(nvm current)" = "v0.6.21" ] || die "v0.6.21-pre not reported as v0.6.21"
|
||||
|
||||
|
10
test/slow/node 0.6.21 should install 0.6.21-pre
Executable file
10
test/slow/node 0.6.21 should install 0.6.21-pre
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
|
||||
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)"
|
||||
[ "_$(nvm current)" = "_v0.6.21" ] || die "v0.6.21-pre not reported as v0.6.21, got $(nvm current)"
|
||||
|
@@ -4,18 +4,27 @@ die () { echo "$@" ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm exec 0.10.28 npm install -g npm@~1.4.11 # this is required because before 1.4.10, npm ls doesn't indicated linked packages
|
||||
nvm exec 0.10.29 npm install -g npm@~1.4.11 # this is required because before 1.4.10, npm ls doesn't indicated linked packages
|
||||
|
||||
nvm use 0.10.28
|
||||
(cd test-npmlink && npm link)
|
||||
|
||||
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp recursive-blame uglify-js yo"
|
||||
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame spawn-sync test-npmlink uglify-js yo"
|
||||
|
||||
echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet
|
||||
echo "$EXPECTED_PACKAGES" | sed -e 's/test-npmlink //' | xargs npm install -g --quiet
|
||||
|
||||
get_packages() {
|
||||
npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs
|
||||
}
|
||||
|
||||
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=$(get_packages)
|
||||
|
||||
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=$(get_packages)
|
||||
|
||||
[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)"
|
||||
[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)"
|
||||
|
||||
[ $(test-npmlink) = 'ok' ] || die "failed to run test-npmlink"
|
||||
|
2
test/slow/nvm reinstall-packages/test-npmlink/index.js
Executable file
2
test/slow/nvm reinstall-packages/test-npmlink/index.js
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
console.log('ok')
|
10
test/slow/nvm reinstall-packages/test-npmlink/package.json
Normal file
10
test/slow/nvm reinstall-packages/test-npmlink/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "test-npmlink",
|
||||
"version": "0.0.1",
|
||||
"description": "Stub package for testing npm link",
|
||||
"bin": {
|
||||
"test-npmlink": "index.js"
|
||||
},
|
||||
"author": "hax",
|
||||
"license": "ISC"
|
||||
}
|
9
test/slow/nvm run/Running "nvm run --harmony --version" should work
Executable file
9
test/slow/nvm run/Running "nvm run --harmony --version" should work
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm run 0.10.7 --harmony --version
|
||||
[ "_$(nvm run 0.10.7 --harmony --version 2>/dev/null | tail -1)" = "_v0.10.7" ] || die "\`nvm run --harmony --version\` failed to run with the correct version"
|
||||
|
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../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 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"
|
@@ -5,5 +5,5 @@ die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ "$(nvm run 0.10.7 --version | tail -1)" = "v0.10.7" ] || die "`nvm run` failed to run with the correct version"
|
||||
[ "$(nvm run 0.10.7 --version | tail -1)" = "v0.10.7" ] || die "\`nvm run\` failed to run with the correct version"
|
||||
|
||||
|
20
test/slow/nvm use/Running "nvm use iojs" uses latest io.js version
Executable file
20
test/slow/nvm use/Running "nvm use iojs" uses latest io.js version
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
|
||||
|
||||
nvm use iojs || die 'nvm use iojs failed'
|
||||
OUTPUT="$(nvm current)"
|
||||
EXPECTED_OUTPUT="iojs-v1.0.1"
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use iojs' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm use --silent iojs)"
|
||||
EXPECTED_OUTPUT=""
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use --silent iojs' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
20
test/slow/nvm use/Running "nvm use node" uses latest stable node version
Executable file
20
test/slow/nvm use/Running "nvm use node" uses latest stable node version
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
|
||||
|
||||
nvm use node || die 'nvm use node failed'
|
||||
OUTPUT="$(nvm current)"
|
||||
EXPECTED_OUTPUT="$(nvm_version stable)"
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use node' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm use --silent node)"
|
||||
EXPECTED_OUTPUT=""
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use --silent node' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
20
test/slow/nvm use/Running "nvm use v1.0.0" uses iojs-v1.0.0 iojs version
Executable file
20
test/slow/nvm use/Running "nvm use v1.0.0" uses iojs-v1.0.0 iojs version
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
|
||||
|
||||
nvm use 'v1.0.0' || die 'nvm use v1.0.0 failed'
|
||||
OUTPUT="$(nvm current)"
|
||||
EXPECTED_OUTPUT="$(nvm_version v1.0.0)"
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||
|
||||
OUTPUT="$(nvm use --silent 'v1.0.0')"
|
||||
EXPECTED_OUTPUT=""
|
||||
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||
|| die "'nvm use --silent v1.0.0' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user