Compare commits

..

98 Commits

Author SHA1 Message Date
Jordan Harband
64de890d07 v0.16.1 2014-09-14 22:24:18 -07:00
Jordan Harband
a4da8a48ef Merge pull request #524 from creationix/run_installation_tests_separately
Run installation tests separately
2014-09-14 22:21:02 -07:00
Jordan Harband
354be52672 Correct installation test paths 2014-09-14 18:01:55 -07:00
Jordan Harband
ad604cc068 Only run the "installation" tests both with and without curl. 2014-09-14 17:25:17 -07:00
Jordan Harband
ba08fa31d8 Moving actual installation tests to their own suite. 2014-09-14 17:24:30 -07:00
Jordan Harband
13aadbcf31 Run slow tests in ksh too 2014-09-14 16:42:23 -07:00
Jordan Harband
7bb6e9c915 Merge pull request #523 from creationix/run_slow_nvmrc_tests_too
Actually run all tests; fix some bugs
2014-09-14 16:38:12 -07:00
Jordan Harband
3d3145f2e0 install: don't output "additional options" when there are none. 2014-09-14 16:04:51 -07:00
Jordan Harband
4c948cf422 install: Ensure that if a version is not provided, we don't try to shift a nonexistent argument. 2014-09-14 16:04:37 -07:00
Jordan Harband
f8054d5cae copy-packages: ensure that nvm_version is also applied to compare the provided version to the current one. 2014-09-14 16:04:25 -07:00
Jordan Harband
ad2713b13a &> is a bash-specific extension for redirecting both stdout and stderr. 2014-09-14 16:04:13 -07:00
Jordan Harband
243fc04164 Fixing these test files that have never been run 2014-09-14 16:04:04 -07:00
Jordan Harband
a80f958a1e All 4 of these test files should be executable. 2014-09-14 16:03:55 -07:00
Jordan Harband
f6fef75f36 Use git in manual install instructions to determine the latest release tag, rather than hardcoding it.
Per 199ba53340
2014-09-13 11:37:19 -07:00
Jordan Harband
199ba53340 Fixing manual install instructions to use the version tag. Relates to #520 2014-09-13 00:59:09 -07:00
Jordan Harband
d1b6332bbe v0.16.0 2014-09-11 00:58:09 -07:00
Jordan Harband
159d4c645e Merge pull request #518 from creationix/nvm_copy_packages_system
Make `nvm copy-packages system` work
2014-09-05 09:05:27 -07:00
Jordan Harband
687df82107 Make nvm copy-packages system work. 2014-09-05 00:43:12 -07:00
Jordan Harband
ff1781b95d Make nvm copy-packages refuse to copy packages from the currently activated version. 2014-09-05 00:42:59 -07:00
Jordan Harband
110e571c34 Make nvm ls system work. 2014-09-05 00:29:20 -07:00
Jordan Harband
a7108e98f2 Make .bashrc be checked first on install.
From #511. Closes #320. Closes #268. Closes #334. Fixes #497. Relates to
2014-09-04 00:54:50 -07:00
Jordan Harband
30b044a368 Merge pull request #511 from 16BITBoy/bashrc-support
Fix for nvm not being sourced to bash when using gnome-terminal in Ubuntu 14.04
2014-09-04 00:53:23 -07:00
Adrian Perez Heredia
825cb46969 Updated error message for missing profile file 2014-09-03 15:07:28 +02:00
Adrian Perez Heredia
ab56ec6675 This patch adds support for terminal emulators. Without this it wont work on gnome-terminal on Ubuntu 2014-09-03 15:07:27 +02:00
Jordan Harband
9d96e4a6bf v0.15.0 2014-09-03 00:08:53 -07:00
Jordan Harband
a00a3a7429 Document NVM_SYMLINK_CURRENT env var from #514. 2014-09-03 00:07:45 -07:00
Jordan Harband
1c3585e5a2 Merge pull request #508 from creationix/nvm_copy_packages_not_npm
Don't copy `npm` with `nvm copy-packages`
2014-09-03 00:01:03 -07:00
Jordan Harband
214ce8853b npm ls has a bug in some versions when "--parseable --depth=0" is used together. 2014-09-02 15:47:45 -07:00
Jordan Harband
d24dc662dc Merge pull request #512 from kevinwang/shasum-lowest-priority
Make shasum the lowest priority checksum command.
2014-09-02 00:36:17 -07:00
Kevin Wang
e8056ac460 Run cleanup on die in nvm_checksum unit test. 2014-08-30 21:57:17 -05:00
Kevin Wang
429656bc41 Add unit tests for nvm_checksum. 2014-08-30 21:54:46 -05:00
Jordan Harband
b61445cbf4 Merge pull request #514 from stelcheck/master
Make the creation of a symlink an overridable default behaviour
2014-08-30 09:49:52 -07:00
Jordan Harband
603253b0cb Quote the version. 2014-08-29 00:12:16 -07:00
Jordan Harband
5ee955bb62 Remove unused $ROOT variable. 2014-08-29 00:12:02 -07:00
stelcheck
83a0efb085 * We print stats only on failure
* || true
2014-08-29 15:01:15 +09:00
stelcheck
9306a9b3f0 * Unit tests 2014-08-29 14:57:30 +09:00
stelcheck
59939d09e8 * Make the creation of a symlink an overridable default behaviour 2014-08-28 22:45:07 +09:00
Jordan Harband
f9769e40dd v0.14.0 2014-08-27 00:49:30 -07:00
Jordan Harband
9c44a3e4c7 Merge pull request #513 from creationix/node_0_6_21_pre
Add special handling for node v0.6.21-pre
2014-08-27 00:38:32 -07:00
Jordan Harband
5048a78376 Add special handling for node v0.6.21-pre 2014-08-26 23:53:17 -07:00
Kevin Wang
814319d7c0 Make shasum the lowest priority checksum command.
This fixes false "Checksums do not match" errors on systems where shasum
is a symlink to sha256sum or otherwise.
2014-08-27 00:06:41 -05:00
Jordan Harband
4b3d6f1760 Properly pass a space-separated list of packages to npm install
Fixes #490.
2014-08-22 02:44:04 -07:00
Jordan Harband
56c40cfa3c Don't try to copy npm itself with nvm copy-packages.
Fixes #504.
2014-08-22 02:19:56 -07:00
Jordan Harband
fd9e01b7e6 Merge pull request #507 from creationix/nvm_ls_current_tests
nvm_ls_current tests
2014-08-22 01:59:14 -07:00
Jordan Harband
5c7f08843d Add error checking to nvm_tree_contains_path 2014-08-21 17:15:53 -07:00
Jordan Harband
6e6c5c4e2a Removing an invalid option to touch from this test. 2014-08-21 17:19:43 -07:00
Jordan Harband
1c2c4788a2 Fixing nvm_version_greater tests.
Relates to #505, #506.
2014-08-21 23:42:51 -07:00
Jordan Harband
b59ecb9e11 Make sure the new versions directory is filtered out of nvm_ls output (in zsh). 2014-08-21 23:39:40 -07:00
Jordan Harband
7551746e55 Merge pull request #505 from magicdrive/fix-error_nvm_version_greater
Fixed `nvm_version_greater` has syntax error in zsh-builtin command `[`
2014-08-21 22:42:05 -07:00
Jordan Harband
70ac1e7fa4 Fix tests so that they fail in zsh (for #505) 2014-08-21 22:40:48 -07:00
Hiroshi IKEGAMI
f130d02efc Fixed nvm_version_greater has syntax error in zsh-buildin-command [ 2014-08-22 10:59:11 +09:00
Jordan Harband
150aea21ec Fixes #487. 2014-08-21 16:51:24 -07:00
Jordan Harband
273f9d497a Adding unit tests for nvm_ls_current. Relates to #487. 2014-08-21 01:35:03 -07:00
Jordan Harband
1c85068091 Merge pull request #502 from creationix/nvm_version_path
Store versions 0.12.0 and newer in a `versions` subdirectory
2014-08-20 22:49:17 -07:00
Jordan Harband
42786630a1 Merge pull request #503 from egilkh/master
Should escape grep in copy-packages.
2014-08-20 10:03:57 -07:00
egilkh
938feca6a9 Should escape grep in copy-packages. 2014-08-20 15:09:40 +02:00
Jordan Harband
3747735980 Make sure nvm clear-cache clears the versions directory as well. 2014-08-20 00:50:15 -07:00
Jordan Harband
5dd2d7e5d4 Make nvm ls support listing the "versions" directory when it's present. 2014-08-20 00:42:50 -07:00
Jordan Harband
65c2435418 Making sure that versions are backed up when running tests. 2014-08-20 00:37:38 -07:00
Jordan Harband
0a695c5d2a Modify nvm_version_path to use nvm_version_greater. 2014-08-20 00:18:29 -07:00
Jordan Harband
8fe677a644 Add nvm_version_greater 2014-08-20 00:01:06 -07:00
Jordan Harband
213ff003d0 Use nvm_version_path everywhere possible. 2014-08-19 16:17:18 -07:00
Jordan Harband
986abbf5db Create nvm_version_path 2014-08-19 16:17:00 -07:00
Jordan Harband
a2da9abd6d Use nvm_version_dir in nvm_version_path 2014-08-19 01:56:34 -07:00
Jordan Harband
9068dda110 Adding nvm_version_dir 2014-08-19 01:53:39 -07:00
Jordan Harband
6baa9a0918 Merge pull request #501 from creationix/fix_copy_packages
Fix nvm copy-packages
2014-08-16 02:35:15 -07:00
Jordan Harband
b8fe75e93a Tests for nvm copy-packages 2014-08-16 01:58:39 -07:00
Jordan Harband
78a5e3fadf Attempt to improve nvm copy-packages 2014-08-16 00:14:29 -07:00
Jordan Harband
5e54886cbc Merge pull request #500 from creationix/run_slow_tests_on_all_shells
Run slow tests on all shells
2014-08-15 21:30:29 -07:00
Jordan Harband
d7849054f8 Apparently wget outputs to stderr, so let's make sure we're checking both stderr and stdout. 2014-08-15 20:47:55 -07:00
Jordan Harband
708ac80a55 Properly replace the -I curl option for the --server-response wget option. 2014-08-15 20:47:55 -07:00
Jordan Harband
d341d5e535 Run all slow tests on all shells 2014-08-08 12:16:22 -07:00
Jordan Harband
eef12cc2b3 v0.13.1 2014-08-08 11:48:54 -07:00
Jordan Harband
99c8b59a14 Make sure that $ARGS is evaluated natively rather than as a single string argument.
Fixes #494.
2014-08-08 11:48:38 -07:00
Jordan Harband
abdc3f3c21 Run all fast tests without curl. 2014-08-07 13:53:12 -07:00
Jordan Harband
401ac45568 Merge pull request #477 from koenpunt/without-curl
add test without curl
2014-08-07 13:52:06 -07:00
Jordan Harband
61709c1f97 v0.13.0 2014-08-02 19:24:39 -07:00
Jordan Harband
1a8479ed31 Merge pull request #491 from creationix/nvm_exec
Add `nvm exec` command.
2014-08-02 19:23:05 -07:00
Jordan Harband
a703d3591f Tweaking the readme description 2014-08-02 19:22:53 -07:00
Jordan Harband
1fa2acf5a7 Adding nvm exec tests. 2014-08-02 15:43:04 -07:00
Jordan Harband
d5c0e94166 Adding nvm exec command. 2014-08-01 01:26:33 -07:00
Jordan Harband
6dc602b521 Ensure that nvm ls node doesn't return "node_modules", for example. 2014-08-01 01:24:28 -07:00
Jordan Harband
1d37af162a v0.12.2 2014-07-29 00:35:27 -07:00
Jordan Harband
781373f7ce Make sure awk is referenced unaliased, per https://github.com/creationix/nvm/issues/162#issuecomment-50284503 2014-07-27 23:02:22 -07:00
Jordan Harband
68574cc7e8 v0.12.1 2014-07-24 14:07:26 -07:00
Jordan Harband
0f3b06320e Merge pull request #481 from johnloy/master
Changes $path var to $node_path. Fixes #482.
2014-07-24 14:07:05 -07:00
John Loy
d181abb628 Changes $path var to $node_path
Avoids obliteration of $path set earlier by Prezto/zsh. Stomping on $path causes dirname to not be in the PATH resulting in an error.
2014-07-24 15:28:33 -04:00
Jordan Harband
f5643dc7ea v0.12.0 2014-07-23 01:15:14 -07:00
Jordan Harband
6bcac7f638 Merge pull request #480 from fjakobs/patch-1
install.sh: make sure to not error out if master branch does not exist
2014-07-23 01:14:41 -07:00
Fabian Jakobs
ad71389dcc master branch might not exist
After a fresh install I was unable to run the installer again. It was breaking with the error

error: branch 'master' not found.

my fix makes sure that the installer continues after that.
2014-07-23 10:08:58 +02:00
Jordan Harband
8cbf149558 Merge pull request #408 from creationix/nvm_system_awareness
Add `system` awareness to `nvm use`, `nvm ls`, and `nvm current`.
2014-07-21 22:55:27 -07:00
Jordan Harband
e7ada80d08 nvm use system should work as expected. 2014-07-21 02:03:18 -07:00
Jordan Harband
9912f7cc46 If nvm is deactivated, display "none" or "system" instead of the system node version 2014-07-21 02:03:18 -07:00
Jordan Harband
6e02e5a54c If nvm_ls is called without a pattern, and node exists, tack on "system". 2014-07-21 02:03:18 -07:00
Jordan Harband
42b010775b Add system support to nvm_print_versions 2014-07-21 02:03:18 -07:00
Jordan Harband
1c50c5c7aa Add nvm_tree_contains_path function 2014-07-21 02:03:04 -07:00
Koen Punt
d67f2b110d string replacement turns out not POSIX compliant 2014-07-18 16:24:03 +02:00
Koen Punt
423629c38b add test without curl 2014-07-18 14:35:22 +02:00
38 changed files with 661 additions and 84 deletions

View File

@@ -1,8 +1,11 @@
language: c # defaults to ruby
install:
- sudo apt-get install ksh zsh -y
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
before_script:
- curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin && chmod +x /tmp/urchin
- '[ -n "$WITHOUT_CURL" ] || curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin'
- '[ -z "$WITHOUT_CURL" ] || wget -O /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin'
- chmod +x /tmp/urchin
script:
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin $SHELL
env:
@@ -12,3 +15,17 @@ env:
- SHELL=zsh TEST_SUITE=fast
- SHELL=ksh TEST_SUITE=fast
- SHELL=sh TEST_SUITE=slow
- SHELL=dash TEST_SUITE=slow
- SHELL=bash TEST_SUITE=slow
- SHELL=zsh TEST_SUITE=slow
- SHELL=ksh TEST_SUITE=slow
- SHELL=sh TEST_SUITE=installation
- SHELL=sh TEST_SUITE=installation WITHOUT_CURL=1
- SHELL=dash TEST_SUITE=installation
- SHELL=dash TEST_SUITE=installation WITHOUT_CURL=1
- SHELL=bash TEST_SUITE=installation
- SHELL=bash TEST_SUITE=installation WITHOUT_CURL=1
- SHELL=zsh TEST_SUITE=installation
- SHELL=zsh TEST_SUITE=installation WITHOUT_CURL=1
- SHELL=ksh TEST_SUITE=installation
- SHELL=ksh TEST_SUITE=installation WITHOUT_CURL=1

View File

@@ -8,11 +8,11 @@ First you'll need to make sure your system has a c++ compiler. For OSX, XCode w
To install you could use the [install script][2] using cURL:
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.2/install.sh | bash
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | bash
or Wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.11.2/install.sh | bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.16.1/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>
@@ -24,9 +24,9 @@ You can customize the install source, directory and profile using the `NVM_SOURC
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in a folder called `nvm`.
Or if you have `git` installed, then just clone it:
Or if you have `git` installed, then just clone it, and check out the latest version:
git clone https://github.com/creationix/nvm.git ~/.nvm
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
To activate nvm, you need to source it from your shell:
@@ -38,7 +38,7 @@ Often I also put in a line to use a specific version of node.
## Usage
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
`nvm use`, `nvm install`, and `nvm run` will all respect an `.nvmrc` file.
`nvm use`, `nvm install`, `nvm exec`, and `nvm run` will all respect an `.nvmrc` file.
To download, compile, and install the latest v0.10.x release of node, do this:
@@ -52,6 +52,10 @@ Or you can just run it:
nvm run 0.10 --version
Or, you can run any arbitrary command in a subshell with the desired version of node:
nvm exec 0.10 node --version
If you want to see what versions are installed:
nvm ls
@@ -75,6 +79,8 @@ To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 0.10
`nvm use` will, by defaut, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to any value other than "true" to disable this behavior.
## License
nvm is released under the MIT license.
@@ -163,7 +169,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.11.2/install.sh
[2]: https://github.com/creationix/nvm/blob/v0.16.1/install.sh
[3]: https://travis-ci.org/creationix/nvm
[Urchin]: https://github.com/scraperwiki/urchin

View File

@@ -18,7 +18,7 @@ nvm_download() {
# Emulate curl with wget
ARGS=$(echo "$*" | sed -e 's/--progress-bar /--progress=bar /' \
-e 's/-L //' \
-e 's/-I //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
@@ -44,12 +44,12 @@ install_nvm_from_git() {
mkdir -p "$NVM_DIR"
git clone "$NVM_SOURCE" "$NVM_DIR"
fi
cd $NVM_DIR && git checkout v0.11.2 && git branch -D master
cd $NVM_DIR && git checkout v0.16.1 && git branch -D master || true
}
install_nvm_as_script() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.11.2/nvm.sh"
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.16.1/nvm.sh"
fi
# Downloading to $NVM_DIR
@@ -96,7 +96,9 @@ echo
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile).
if [ -z "$PROFILE" ]; then
if [ -f "$HOME/.bash_profile" ]; then
if [ -f "$HOME/.bashrc" ]; then
PROFILE="$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.zshrc" ]; then
PROFILE="$HOME/.zshrc"
@@ -109,7 +111,7 @@ SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
if [ -z "$PROFILE" ]; then
echo "=> Profile not found. Tried ~/.bash_profile, ~/.zshrc, and ~/.profile."
echo "=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
echo "=> Create one of them and run this script again"
else
echo "=> Profile $PROFILE not found"

232
nvm.sh
View File

@@ -19,11 +19,11 @@ nvm_download() {
# Emulate curl with wget
ARGS=$(echo "$*" | sed -e 's/--progress-bar /--progress=bar /' \
-e 's/-L //' \
-e 's/-I //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
wget $ARGS
eval wget $ARGS
fi
}
@@ -53,6 +53,25 @@ if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
fi
nvm_tree_contains_path() {
local tree
tree="$1"
local node_path
node_path="$2"
if [ "@$tree@" = "@@" ] || [ "@$node_path@" = "@@" ]; then
>&2 echo "both the tree and the node path are required"
return 2
fi
local pathdir
pathdir=$(dirname "$node_path")
while [ "$pathdir" != "" ] && [ "$pathdir" != "." ] && [ "$pathdir" != "/" ] && [ "$pathdir" != "$tree" ]; do
pathdir=$(dirname "$pathdir")
done
[ "$pathdir" = "$tree" ]
}
# Traverse up in directory tree to find containing folder
nvm_find_up() {
local path
@@ -82,6 +101,40 @@ nvm_rc_version() {
fi
}
nvm_version_greater() {
local LHS
LHS=$(echo "$1" | awk -F. '{for (i=1;i<=NF;++i) printf "%010d",$i}')
local RHS
RHS=$(echo "$2" | awk -F. '{for (i=1;i<=NF;++i) printf "%010d",$i}')
[ $LHS -gt $RHS ];
}
nvm_version_dir() {
local NVM_USE_NEW_DIR
NVM_USE_NEW_DIR="$1"
if [ -z "$NVM_USE_NEW_DIR" ] || [ "$NVM_USE_NEW_DIR" = "new" ]; then
echo "$NVM_DIR/versions"
elif [ "$NVM_USE_NEW_DIR" = "old" ]; then
echo "$NVM_DIR"
else
echo "unknown version dir" >&2
return 3
fi
}
nvm_version_path() {
local VERSION
VERSION="$1"
if [ -z "$VERSION" ]; then
echo "version is required" >&2
return 3
elif nvm_version_greater 0.12.0 "$VERSION"; then
echo "$(nvm_version_dir old)/$VERSION"
else
echo "$(nvm_version_dir new)/$VERSION"
fi
}
# Expand a version using the version cache
nvm_version() {
local PATTERN
@@ -118,7 +171,7 @@ nvm_remote_version() {
}
nvm_normalize_version() {
echo "$1" | sed -e 's/^v//' | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'
echo "$1" | sed -e 's/^v//' | \awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'
}
nvm_format_version() {
@@ -147,7 +200,21 @@ nvm_binary_available() {
}
nvm_ls_current() {
echo `node -v 2>/dev/null`
local NODE_PATH
NODE_PATH="$(which node 2> /dev/null)"
if [ $? -ne 0 ]; then
echo 'none'
elif nvm_tree_contains_path "$NVM_DIR" "$NODE_PATH"; then
local VERSION
VERSION=`node -v 2>/dev/null`
if [ "$VERSION" = "v0.6.21-pre" ]; then
echo "v0.6.21"
else
echo "$VERSION"
fi
else
echo 'system'
fi
}
nvm_ls() {
@@ -166,7 +233,7 @@ nvm_ls() {
fi
# If it looks like an explicit version, don't do anything funny
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then
if [ -d "$NVM_DIR/$PATTERN" ]; then
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
VERSIONS="$PATTERN"
fi
else
@@ -174,13 +241,28 @@ nvm_ls() {
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*$"` != 0 ]; then
PATTERN="$PATTERN."
fi
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.'`
if [ -d "$(nvm_version_dir new)" ]; then
VERSIONS=`find "$(nvm_version_dir new)/" "$(nvm_version_dir old)/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.' | \grep -e '^v' | \grep -v -e '^versions$'`
else
VERSIONS=`find "$(nvm_version_dir old)/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.' | \grep -e '^v'`
fi
fi
if nvm_has_system_node; then
if [ -z "$PATTERN" ]; then
VERSIONS="$VERSIONS$(printf '\n%s' 'system')"
elif [ "$PATTERN" = 'system' ]; then
VERSIONS="$(printf '%s' 'system')"
fi
fi
if [ -z "$VERSIONS" ]; then
echo "N/A"
return 3
fi
echo "$VERSIONS"
return
}
@@ -209,12 +291,12 @@ nvm_ls_remote() {
}
nvm_checksum() {
if nvm_has "shasum"; then
checksum=$(shasum $1 | awk '{print $1}')
if nvm_has "sha1sum"; then
checksum=$(sha1sum $1 | \awk '{print $1}')
elif nvm_has "sha1"; then
checksum=$(sha1 -q $1)
else
checksum=$(sha1sum $1 | awk '{print $1}')
checksum=$(shasum $1 | \awk '{print $1}')
fi
if [ "$checksum" = "$2" ]; then
@@ -236,8 +318,10 @@ nvm_print_versions() {
echo "$1" | while read VERSION; do
if [ "$VERSION" = "$NVM_CURRENT" ]; then
FORMAT='\033[0;32m-> %9s\033[0m'
elif [ -d "$NVM_DIR/$VERSION" ]; then
elif [ -d "$(nvm_version_path "$VERSION")" ]; then
FORMAT='\033[0;34m%12s\033[0m'
elif [ "$VERSION" = "system" ]; then
FORMAT='\033[0;33m%12s\033[0m'
else
FORMAT='%12s'
fi
@@ -349,26 +433,27 @@ nvm() {
fi
provided_version=$1
if [ -z "$provided_version" ]; then
if [ $version_not_provided -ne 1 ]; then
nvm_rc_version
fi
provided_version="$NVM_RC_VERSION"
else
shift
fi
[ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." >&2 && return
[ -d "$(nvm_version_path "$provided_version")" ] && echo "$provided_version is already installed." >&2 && return
VERSION=`nvm_remote_version $provided_version`
ADDITIONAL_PARAMETERS=''
shift
while [ $# -ne 0 ]
do
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
shift
done
if [ -d "$NVM_DIR/$VERSION" ]; then
if [ -d "$(nvm_version_path "$VERSION")" ]; then
echo "$VERSION is already installed." >&2
nvm use "$VERSION"
return $?
@@ -386,7 +471,7 @@ nvm() {
if nvm_binary_available "$VERSION"; then
t="$VERSION-$os-$arch"
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-${t}.tar.gz | awk '{print $1}'`
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-${t}.tar.gz | \awk '{print $1}'`
local tmpdir
tmpdir="$NVM_DIR/bin/node-${t}"
local tmptarball
@@ -397,7 +482,7 @@ nvm() {
nvm_checksum "$tmptarball" $sum && \
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
rm -f "$tmptarball" && \
mv "$tmpdir" "$NVM_DIR/$VERSION"
mv "$tmpdir" "$(nvm_version_path "$VERSION")"
)
then
nvm use $VERSION
@@ -410,7 +495,9 @@ nvm() {
fi
fi
echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
if [ -n "$ADDITIONAL_PARAMETERS" ]; then
echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
fi
tarball=''
sum=''
@@ -423,9 +510,9 @@ nvm() {
tmpdir="$NVM_DIR/src"
local tmptarball
tmptarball="$tmpdir/node-$VERSION.tar.gz"
if [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
if [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - 2>&1 | \grep '200 OK'`" != '' ]; then
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-$VERSION.tar.gz | awk '{print $1}'`
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-$VERSION.tar.gz | \awk '{print $1}'`
elif [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz"
fi
@@ -436,9 +523,9 @@ nvm() {
nvm_checksum "$tmptarball" $sum && \
tar -xzf "$tmptarball" -C "$tmpdir" && \
cd "$tmpdir/node-$VERSION" && \
./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \
./configure --prefix="$(nvm_version_path "$VERSION")" $ADDITIONAL_PARAMETERS && \
$make $MAKE_CXX && \
rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \
rm -f "$(nvm_version_path "$VERSION")" 2>/dev/null && \
$make $MAKE_CXX install
)
then
@@ -470,7 +557,7 @@ nvm() {
return 1
fi
VERSION=`nvm_version $PATTERN`
if [ ! -d $NVM_DIR/$VERSION ]; then
if [ ! -d "$(nvm_version_path "$VERSION")" ]; then
echo "$VERSION version is not installed..." >&2
return;
fi
@@ -482,7 +569,7 @@ nvm() {
"$NVM_DIR/src/node-$VERSION.tar.gz" \
"$NVM_DIR/bin/node-${t}" \
"$NVM_DIR/bin/node-${t}.tar.gz" \
"$NVM_DIR/$VERSION" 2>/dev/null
"$(nvm_version_path "$VERSION")" 2>/dev/null
echo "Uninstalled node $VERSION"
# Rm any aliases that point to uninstalled version.
@@ -524,7 +611,17 @@ nvm() {
VERSION=`nvm_version $NVM_RC_VERSION`
fi
else
VERSION=`nvm_version $2`
if [ $2 = 'system' ]; then
if nvm_has_system_node && nvm deactivate; then
echo "Now using system version of node: $(node -v 2>/dev/null)."
return
else
echo "System version of node not found." >&2
return 127
fi
else
VERSION=`nvm_version $2`
fi
fi
if [ -z "$VERSION" ]; then
nvm help
@@ -533,32 +630,36 @@ nvm() {
if [ -z "$VERSION" ]; then
VERSION=`nvm_version $2`
fi
if [ ! -d "$NVM_DIR/$VERSION" ]; then
local NVM_VERSION_DIR
NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
if [ ! -d "$NVM_VERSION_DIR" ]; then
echo "$VERSION version is not installed yet" >&2
return 1
fi
# Strip other version from PATH
PATH=`nvm_strip_path "$PATH" "/bin"`
# Prepend current version
PATH=`nvm_prepend_path "$PATH" "$NVM_DIR/$VERSION/bin"`
PATH=`nvm_prepend_path "$PATH" "$NVM_VERSION_DIR/bin"`
if [ -z "$MANPATH" ]; then
MANPATH=$(manpath)
fi
# Strip other version from MANPATH
MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
# Prepend current version
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_DIR/$VERSION/share/man"`
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man"`
# Strip other version from NODE_PATH
NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
# Prepend current version
NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`
NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"`
export PATH
hash -r
export MANPATH
export NODE_PATH
export NVM_PATH="$NVM_DIR/$VERSION/lib/node"
export NVM_BIN="$NVM_DIR/$VERSION/bin"
rm -f "$NVM_DIR/current" && ln -s "$NVM_DIR/$VERSION" "$NVM_DIR/current"
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
export NVM_BIN="$NVM_VERSION_DIR/bin"
if [ "$NVM_SYMLINK_CURRENT" = true ] || [ -z "$NVM_SYMLINK_CURRENT" ]; then
rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
fi
echo "Now using node $VERSION"
;;
"run" )
@@ -594,14 +695,41 @@ nvm() {
fi
fi
if [ ! -d "$NVM_DIR/$VERSION" ]; then
local NVM_VERSION_DIR
NVM_VERSION_DIR=$(nvm_version_path "$VERSION")
if [ ! -d "$NVM_VERSION_DIR" ]; then
echo "$VERSION version is not installed yet" >&2
return 1
fi
RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`
RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"`
echo "Running node $VERSION"
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
NODE_PATH=$RUN_NODE_PATH $NVM_VERSION_DIR/bin/node "$@"
;;
"exec" )
shift
local provided_version
provided_version=$1
if [ -n "$provided_version" ]; then
VERSION=`nvm_version $provided_version`
if [ $VERSION = "N/A" ]; then
provided_version=''
nvm_rc_version
VERSION=`nvm_version $NVM_RC_VERSION`
else
shift
fi
fi
local NVM_VERSION_DIR
NVM_VERSION_DIR=$(nvm_version_path "$VERSION")
if [ ! -d "$NVM_VERSION_DIR" ]; then
echo "$VERSION version is not installed yet" >&2
return 1
fi
echo "Running node $VERSION"
NODE_VERSION=$VERSION $NVM_DIR/nvm-exec "$@"
;;
"ls" | "list" )
local NVM_LS_OUTPUT
@@ -667,30 +795,42 @@ nvm() {
nvm help
return 127
fi
VERSION=`nvm_version $2`
local ROOT
ROOT=`(nvm use $VERSION && npm -g root)`
local ROOTDEPTH
ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1))
# declare local INSTALLS first, otherwise it doesn't work in zsh
local PROVIDED_VERSION
PROVIDED_VERSION="$2"
if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ] || [ "$(nvm_version $PROVIDED_VERSION)" = "$(nvm_ls_current)" ]; then
echo 'Can not copy packages from the current version of node.' >&2
return 2
fi
local INSTALLS
INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f $(($ROOTDEPTH + 2)) | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "`
if [ "$PROVIDED_VERSION" = "system" ]; then
if ! nvm_has_system_node; then
echo 'No system version of node detected.' >&2
return 3
fi
INSTALLS=$(nvm deactivate > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs)
else
local VERSION
VERSION="$(nvm_version "$PROVIDED_VERSION")"
INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs)
fi
npm install -g ${INSTALLS[@]}
echo "$INSTALLS" | xargs npm install -g --quiet
;;
"clear-cache" )
rm -f $NVM_DIR/v* 2>/dev/null
rm -f $NVM_DIR/v* "$(nvm_version_dir)" 2>/dev/null
echo "Cache cleared."
;;
"version" )
nvm_version $2
;;
"--version" )
echo "0.11.2"
echo "0.16.1"
;;
"unload" )
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version > /dev/null 2>&1
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater > /dev/null 2>&1
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
;;
* )

View File

@@ -1,6 +1,6 @@
{
"name": "nvm",
"version": "0.11.2",
"version": "0.16.1",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": {
"test": "test"
@@ -8,7 +8,8 @@
"scripts": {
"test": "urchin test",
"test/fast": "urchin -f test/fast",
"test/slow": "urchin -f test/slow"
"test/slow": "urchin -f test/slow",
"test/installation": "urchin -f test/installation"
},
"repository": {
"type": "git",

View File

@@ -0,0 +1,7 @@
#!/bin/sh
. ../../../nvm.sh
nvm ls node
[ "$?" = "3" ]

View File

@@ -0,0 +1,22 @@
#!/bin/sh
cleanup () { unset -f nvm_has_system_node; }
die () { cleanup ; echo $@ ; exit 1; }
. ../../../nvm.sh
mkdir -p ../../../v0.0.1
mkdir -p ../../../v0.0.3
mkdir -p ../../../v0.0.9
mkdir -p ../../../v0.3.1
mkdir -p ../../../v0.3.3
mkdir -p ../../../v0.3.9
nvm_has_system_node() { return 0; }
nvm ls system | grep system 2>&1 > /dev/null
[ $? -eq 0 ] || die '"nvm ls system" did not contain "system" when system node is present'
nvm_has_system_node() { return 1; }
nvm ls system | grep system 2>&1 > /dev/null
[ $? -ne 0 ] || die '"nvm ls system" contained "system" when system node is not present'

View File

@@ -0,0 +1,14 @@
#!/bin/sh
mkdir ../../../v0.1.3
mkdir ../../../v0.2.3
. ../../../nvm.sh
mkdir ../../../versions
[ -z "$(nvm ls | \grep 'versions')" ]
# The result should contain only the appropriate version numbers.
rmdir ../../../versions

View File

@@ -0,0 +1,21 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
mkdir -p ../../../v0.0.1
mkdir -p ../../../v0.0.3
mkdir -p ../../../v0.0.9
mkdir -p ../../../v0.3.1
mkdir -p ../../../v0.3.3
mkdir -p ../../../v0.3.9
nvm_has_system_node() { return 0; }
nvm ls | grep system 2>&1 > /dev/null
[ $? -eq 0 ] || die '"nvm ls" did not contain "system" when system node is present'
nvm_has_system_node() { return 1; }
nvm ls | grep system 2>&1 > /dev/null
[ $? -ne 0 ] || die '"nvm ls" contained "system" when system node is not present'

View File

@@ -0,0 +1,12 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
mkdir -p ../../../versions/v0.12.1
mkdir ../../../v0.1.3
. ../../../nvm.sh
nvm ls 0.12 | grep v0.12.1 || die '"nvm ls" did not list a version in the versions/ directory'
nvm ls 0.1 | grep v0.1.3 || die '"nvm ls" did not list a version not in the versions/ directory'

1
test/fast/Listing versions/teardown Normal file → Executable file
View File

@@ -7,5 +7,6 @@ rmdir ../../../v0.2.3
rmdir ../../../v0.3.1
rmdir ../../../v0.3.3
rmdir ../../../v0.3.9
rmdir ../../../versions
unalias nvm_has_system_node

View File

@@ -3,4 +3,8 @@
die () { echo $@ ; exit 1; }
. ../../nvm.sh
[ "$(nvm current)" = "$(node -v)" ] || die "Failed to find current version"
nvm deactivate 2>&1
[ "$(nvm current)" = "system" ] || [ "$(nvm current)" = "none" ] || die '"nvm current" did not report "system" or "none" when deactivated'

View File

@@ -0,0 +1,13 @@
#!/bin/sh
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_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 use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"

View File

@@ -0,0 +1,83 @@
#!/bin/bash
. ../../nvm.sh
TEST_NODE_VERSION="v0.10.29"
TEST_COUNT=0
TEST_PASSED=0
TEST_FAILED=0
function registerExpectedSymlink() {
registerResult ${1}
}
function registerExpectedNoSymlink() {
[ ${1} -ne 0 ]
registerResult $?
}
function registerResult() {
result=${1}
TEST_COUNT=$(($TEST_COUNT + 1))
[ ${result} -eq 0 ] \
&& TEST_PASSED=$(($TEST_PASSED + 1)) \
|| TEST_FAILED=$(($TEST_FAILED + 1))
}
function cleanup() {
rm -rf ../../${TEST_NODE_VERSION}
rm -f ../../current
}
function runNvmUse() {
mkdir ../../${TEST_NODE_VERSION}
nvm use ${TEST_NODE_VERSION} > /dev/null 2>&1
rmdir ../../${TEST_NODE_VERSION}
}
function isCurrentSymlinkPresent() {
[ -L ../../current ]
}
NVM_SYMLINK_CURRENT=false
cleanup
runNvmUse
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=false!"
registerExpectedNoSymlink $?
NVM_SYMLINK_CURRENT=true
cleanup
runNvmUse
isCurrentSymlinkPresent || echo "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT=true!"
registerExpectedSymlink $?
NVM_SYMLINK_CURRENT=garbagevalue
cleanup
runNvmUse
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT contains a string!"
registerExpectedNoSymlink $?
NVM_SYMLINK_CURRENT=0
cleanup
runNvmUse
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=0!"
registerExpectedNoSymlink $?
NVM_SYMLINK_CURRENT=1
cleanup
runNvmUse
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=1!"
registerExpectedNoSymlink $?
unset NVM_SYMLINK_CURRENT
cleanup
runNvmUse
isCurrentSymlinkPresent || echo "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT has been unset (default behaviour)!"
registerExpectedSymlink $?
cleanup
[ ${TEST_FAILED} -ne 0 ] && echo "${TEST_COUNT} tested, ${TEST_PASSED} passed, ${TEST_FAILED} failed" && exit 1 || true

View File

@@ -0,0 +1,18 @@
#!/bin/sh
cleanup () {
rm tmp/emptyfile tmp/testfile
rmdir tmp
}
die () { echo $@ ; cleanup; exit 1; }
. ../../../nvm.sh
mkdir -p tmp
touch tmp/emptyfile
echo -n "test" > tmp/testfile
nvm_checksum tmp/emptyfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" || die "nvm_checksum on an empty file did not match the SHA1 digest of the empty string"
nvm_checksum tmp/testfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" && die "nvm_checksum allowed a bad checksum"
cleanup

View File

@@ -0,0 +1,28 @@
#!/bin/sh
die () { echo $@ ; 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"'
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"
[ "$(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'
echo "#!/bin/bash" > "$TEST_DIR/node"
echo "echo 'VERSION FOO!'" > "$TEST_DIR/node"
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"

View File

@@ -0,0 +1,32 @@
#!/bin/sh
cleanup () {
rm tmp/node
rmdir tmp
rm tmp2/node
rmdir tmp2
}
die () { echo $@ ; cleanup; exit 1; }
. ../../../nvm.sh
mkdir -p tmp
touch tmp/node
mkdir -p tmp2
touch tmp2/node
[ "$(nvm_tree_contains_path 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with no args'
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with no args'
[ "$(nvm_tree_contains_path tmp 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with one arg'
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with one arg'
nvm_tree_contains_path tmp tmp/node || die '"tmp" should contain "tmp/node"'
nvm_tree_contains_path tmp tmp2/node && die '"tmp" should not contain "tmp2/node"'
nvm_tree_contains_path tmp2 tmp2/node || die '"tmp2" should contain "tmp2/node"'
nvm_tree_contains_path tmp2 tmp/node && die '"tmp2" should not contain "tmp/node"'
cleanup

View File

@@ -0,0 +1,11 @@
#!/bin/sh
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 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'

View File

@@ -0,0 +1,16 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm_version_greater 0.10.0 0.2.12 || die '"nvm_version_greater 0.10.0 0.2.12" did not return true'
if nvm_version_greater 0.10.0 0.20.12; then
die '"nvm_version_greater 0.10.0 0.20.12" returned true'
fi
if nvm_version_greater 0.10.0 0.10.0; then
die '"nvm_version_greater" returned false for the same two versions'
fi

View File

@@ -0,0 +1,11 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(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'

View File

@@ -9,5 +9,8 @@
for SRC in v* src alias; do
[ -e "$SRC" ] && mv "$SRC" bak
done
if [ -d versions ]; then
mv versions bak
fi
true
)

View File

@@ -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

View File

@@ -1,17 +1,17 @@
#!/bin/sh
set -e
. ../../../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
# Check
[ -d ../../../$NVM_TEST_VERSION ]
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -1,17 +1,17 @@
#!/bin/sh
set -e
. ../../../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
# Check
[ -d ../../../$NVM_TEST_VERSION ]
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -1,19 +1,19 @@
#!/bin/sh
set -e
. ../../../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
nvm i 0.9.12
# Check
[ -d ../../../v0.9.7 ]
[ -d ../../../v0.9.12 ]
[ -d ../../v0.9.7 ]
[ -d ../../v0.9.12 ]
# Use the first one
nvm use 0.9.7

View File

@@ -1,20 +1,20 @@
#!/bin/sh
set -e
. ../../../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
cat "$NVM_TEST_VERSION" > .nvmrc
echo "$NVM_TEST_VERSION" > .nvmrc
nvm install
# Check
[ -d ../../../$NVM_TEST_VERSION ]
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -1,20 +1,20 @@
#!/bin/sh
set -e
. ../../../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
cat "$NVM_TEST_VERSION" > .nvmrc
echo "$NVM_TEST_VERSION" > .nvmrc
nvm install -s
# Check
[ -d ../../../$NVM_TEST_VERSION ]
[ -d ../../$NVM_TEST_VERSION ]
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. ../../../nvm.sh
. ../../nvm.sh
nvm uninstall v0.10.7
if [ -f ".nvmrc" ]; then

View File

@@ -8,3 +8,7 @@ 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"

View File

@@ -0,0 +1,16 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm use 0.10.28 > /dev/null
EXPECTED_MSG="Can not copy packages from the current version of node."
ACTUAL_MSG="$(nvm copy-packages 0.10.28 2>&1 > /dev/null)"
[ "~$ACTUAL_MSG" = "~$EXPECTED_MSG" ] || die "'nvm use 0.10.28 && nvm copy-packages 0.10.28' did not fail with the right message: '$ACTUAL_MESSAGE'"
EXPECTED_ERROR_CODE="2"
ACTUAL_ERROR_CODE="$(nvm copy-packages 0.10.28 > /dev/null 2>&1 ; echo $?)"
[ "~$ACTUAL_ERROR_CODE" = "~$EXPECTED_ERROR_CODE" ] || die "'nvm use 0.10.28 && nvm copy-packages 0.10.28' did not fail with the right error code: expected '$EXPECTED_ERROR_CODE', got '$ACTUAL_ERROR_CODE'"

View File

@@ -0,0 +1,10 @@
#!/bin/sh
. ../../../nvm.sh
nvm install 0.10.28
nvm install 0.10.29
if [ -f ".nvmrc" ]; then
mv .nvmrc .nvmrc.bak
fi

View File

@@ -0,0 +1,21 @@
#!/bin/sh
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
nvm use 0.10.28
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp recursive-blame uglify-js yo"
echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet
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)
nvm copy-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" = "$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)"

View File

@@ -0,0 +1,12 @@
#!/bin/sh
. ../../../nvm.sh
nvm uninstall v0.10.28
nvm uninstall v0.10.29
rm -f .nvmrc
if [ -f ".nvmrc.bak" ]; then
mv .nvmrc.bak .nvmrc
fi

View File

@@ -0,0 +1,13 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm use 0.10
NPM_VERSION_TEN="$(npm --version)"
nvm use 0.11.7 && [ "$(node --version)" = "v0.11.7" ] || die "\`nvm use\` failed!"
[ "$(nvm exec 0.10 npm --version | tail -1)" = "$NPM_VERSION_TEN" ] || die "`nvm exec` failed to run with the correct version"

View File

@@ -0,0 +1,17 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm use 0.10.7
NPM_VERSION_TEN="$(npm --version)"
nvm use 0.11.7 && [ "$(node --version)" = "v0.11.7" ] || die "\`nvm use\` failed!"
echo "0.10.7" > .nvmrc
[ "$(nvm exec npm --version | tail -1)" = "$NPM_VERSION_TEN" ] || die "\`nvm exec\` failed to run with the .nvmrc version"
[ "$(nvm exec npm --version | head -1)" = "Found '$PWD/.nvmrc' with version <0.10.7>" ] || die "\`nvm exec\` failed to print out the \"found in .nvmrc\" message"

10
test/slow/nvm exec/setup_dir Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
. ../../../nvm.sh
nvm install 0.10.7
nvm install 0.11.7
if [ -f ".nvmrc" ]; then
mv .nvmrc .nvmrc.bak
fi

12
test/slow/nvm exec/teardown_dir Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
. ../../../nvm.sh
nvm uninstall v0.10.7
nvm uninstall v0.11.7
rm .nvmrc
if [ -f ".nvmrc.bak" ]; then
mv .nvmrc.bak .nvmrc
fi