mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-03 02:56:31 +00:00
Compare commits
202 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d1b6332bbe | ||
![]() |
159d4c645e | ||
![]() |
687df82107 | ||
![]() |
ff1781b95d | ||
![]() |
110e571c34 | ||
![]() |
a7108e98f2 | ||
![]() |
30b044a368 | ||
![]() |
825cb46969 | ||
![]() |
ab56ec6675 | ||
![]() |
9d96e4a6bf | ||
![]() |
a00a3a7429 | ||
![]() |
1c3585e5a2 | ||
![]() |
214ce8853b | ||
![]() |
d24dc662dc | ||
![]() |
e8056ac460 | ||
![]() |
429656bc41 | ||
![]() |
b61445cbf4 | ||
![]() |
603253b0cb | ||
![]() |
5ee955bb62 | ||
![]() |
83a0efb085 | ||
![]() |
9306a9b3f0 | ||
![]() |
59939d09e8 | ||
![]() |
f9769e40dd | ||
![]() |
9c44a3e4c7 | ||
![]() |
5048a78376 | ||
![]() |
814319d7c0 | ||
![]() |
4b3d6f1760 | ||
![]() |
56c40cfa3c | ||
![]() |
fd9e01b7e6 | ||
![]() |
5c7f08843d | ||
![]() |
6e6c5c4e2a | ||
![]() |
1c2c4788a2 | ||
![]() |
b59ecb9e11 | ||
![]() |
7551746e55 | ||
![]() |
70ac1e7fa4 | ||
![]() |
f130d02efc | ||
![]() |
150aea21ec | ||
![]() |
273f9d497a | ||
![]() |
1c85068091 | ||
![]() |
42786630a1 | ||
![]() |
938feca6a9 | ||
![]() |
3747735980 | ||
![]() |
5dd2d7e5d4 | ||
![]() |
65c2435418 | ||
![]() |
0a695c5d2a | ||
![]() |
8fe677a644 | ||
![]() |
213ff003d0 | ||
![]() |
986abbf5db | ||
![]() |
a2da9abd6d | ||
![]() |
9068dda110 | ||
![]() |
6baa9a0918 | ||
![]() |
b8fe75e93a | ||
![]() |
78a5e3fadf | ||
![]() |
5e54886cbc | ||
![]() |
d7849054f8 | ||
![]() |
708ac80a55 | ||
![]() |
d341d5e535 | ||
![]() |
eef12cc2b3 | ||
![]() |
99c8b59a14 | ||
![]() |
abdc3f3c21 | ||
![]() |
401ac45568 | ||
![]() |
61709c1f97 | ||
![]() |
1a8479ed31 | ||
![]() |
a703d3591f | ||
![]() |
1fa2acf5a7 | ||
![]() |
d5c0e94166 | ||
![]() |
6dc602b521 | ||
![]() |
1d37af162a | ||
![]() |
781373f7ce | ||
![]() |
68574cc7e8 | ||
![]() |
0f3b06320e | ||
![]() |
d181abb628 | ||
![]() |
f5643dc7ea | ||
![]() |
6bcac7f638 | ||
![]() |
ad71389dcc | ||
![]() |
8cbf149558 | ||
![]() |
e7ada80d08 | ||
![]() |
9912f7cc46 | ||
![]() |
6e02e5a54c | ||
![]() |
42b010775b | ||
![]() |
1c50c5c7aa | ||
![]() |
200a9aa97e | ||
![]() |
4512337c11 | ||
![]() |
55677dba4a | ||
![]() |
ca43ca21f5 | ||
![]() |
fafbeb8c59 | ||
![]() |
d67f2b110d | ||
![]() |
9c2127ce33 | ||
![]() |
423629c38b | ||
![]() |
5ec0ccec1b | ||
![]() |
7a423b7bb4 | ||
![]() |
a3de7f3222 | ||
![]() |
55d892adc8 | ||
![]() |
3b42df8d1d | ||
![]() |
21fa84225c | ||
![]() |
4895aebf0a | ||
![]() |
8a29122d0a | ||
![]() |
26ed7a003a | ||
![]() |
00ca5288b0 | ||
![]() |
6d2912a2ab | ||
![]() |
1d61584402 | ||
![]() |
f6974744cd | ||
![]() |
7171cbed6f | ||
![]() |
8f66273922 | ||
![]() |
1a9ab82e24 | ||
![]() |
3fa004293c | ||
![]() |
83efa2288d | ||
![]() |
4cfe62d3d1 | ||
![]() |
802f064178 | ||
![]() |
c49cb68575 | ||
![]() |
0534872e0f | ||
![]() |
f1b8cf8fd6 | ||
![]() |
78ff9a2215 | ||
![]() |
b952be6f56 | ||
![]() |
638ae5c6fa | ||
![]() |
a7b6495172 | ||
![]() |
703e43cc2b | ||
![]() |
03636878d1 | ||
![]() |
2ee4b6f414 | ||
![]() |
10305f0791 | ||
![]() |
276c031c60 | ||
![]() |
63f72b37df | ||
![]() |
cf5bfecec4 | ||
![]() |
77c3f20956 | ||
![]() |
e4ada9fa43 | ||
![]() |
a0de15d0f7 | ||
![]() |
df4689fbd2 | ||
![]() |
018e47bec0 | ||
![]() |
74cc1eb022 | ||
![]() |
eda8ffbcc4 | ||
![]() |
b9383c9016 | ||
![]() |
25c0be1e20 | ||
![]() |
a8233eb68c | ||
![]() |
ea198c9a19 | ||
![]() |
e0537ce3df | ||
![]() |
cce5df35ba | ||
![]() |
7e269961c3 | ||
![]() |
f214ffaf1f | ||
![]() |
d016fe010a | ||
![]() |
fb5a51b1b7 | ||
![]() |
3e5037a1be | ||
![]() |
60fec40613 | ||
![]() |
fb215546ee | ||
![]() |
4b593bcda2 | ||
![]() |
8349f0ff48 | ||
![]() |
bb250b5730 | ||
![]() |
b6f1c156da | ||
![]() |
4c9a36e9ad | ||
![]() |
bb01513eba | ||
![]() |
ba7f27dead | ||
![]() |
79ec957ee7 | ||
![]() |
d8b55652a5 | ||
![]() |
4c38f507f5 | ||
![]() |
f213167ef0 | ||
![]() |
1da31aa425 | ||
![]() |
519a9481e6 | ||
![]() |
b16bf303ca | ||
![]() |
9a28706688 | ||
![]() |
a318ddf9b3 | ||
![]() |
8dbbc32905 | ||
![]() |
de03007348 | ||
![]() |
1b22c2e2b1 | ||
![]() |
0e1f2408c9 | ||
![]() |
931cc45fc3 | ||
![]() |
085e314a3f | ||
![]() |
6aa45732d8 | ||
![]() |
16c0be8314 | ||
![]() |
578a601b27 | ||
![]() |
896aa7c436 | ||
![]() |
2441b00262 | ||
![]() |
88595f09aa | ||
![]() |
5925bd5e37 | ||
![]() |
24e22dd8bc | ||
![]() |
61de5f9ca3 | ||
![]() |
4de9eff55c | ||
![]() |
7e20a77c89 | ||
![]() |
8fbbeb8fc5 | ||
![]() |
79203ba5d0 | ||
![]() |
2e3e48cc06 | ||
![]() |
db8acf11fd | ||
![]() |
a6be718387 | ||
![]() |
e2c4c88136 | ||
![]() |
4cd0b078d0 | ||
![]() |
f6ba08253b | ||
![]() |
0ecb2879b9 | ||
![]() |
e3b84499c2 | ||
![]() |
b313f62749 | ||
![]() |
7f3a794d89 | ||
![]() |
ba1be9b4ea | ||
![]() |
652a9ef9b5 | ||
![]() |
0d81a219ae | ||
![]() |
d6e457354f | ||
![]() |
6668dc5c47 | ||
![]() |
3d9c1d7852 | ||
![]() |
29f582611b | ||
![]() |
673cda56c4 | ||
![]() |
e562a5645b | ||
![]() |
c0c5e8d7ef | ||
![]() |
f00d688c87 | ||
![]() |
5aa78f21cf | ||
![]() |
703acb0514 | ||
![]() |
744507b83e |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,4 +11,4 @@ test/bak
|
||||
node_modules/
|
||||
|
||||
.DS_Store
|
||||
|
||||
current
|
||||
|
27
.travis.yml
27
.travis.yml
@@ -1,8 +1,29 @@
|
||||
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 URCHIN=/tmp/urchin test
|
||||
|
||||
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin $SHELL
|
||||
env:
|
||||
- SHELL=sh TEST_SUITE=fast
|
||||
- SHELL=sh TEST_SUITE=fast WITHOUT_CURL=1
|
||||
- SHELL=dash TEST_SUITE=fast
|
||||
- SHELL=dash TEST_SUITE=fast WITHOUT_CURL=1
|
||||
- SHELL=bash TEST_SUITE=fast
|
||||
- SHELL=bash TEST_SUITE=fast WITHOUT_CURL=1
|
||||
- SHELL=zsh TEST_SUITE=fast
|
||||
- SHELL=zsh TEST_SUITE=fast WITHOUT_CURL=1
|
||||
- SHELL=ksh TEST_SUITE=fast
|
||||
- SHELL=ksh TEST_SUITE=fast WITHOUT_CURL=1
|
||||
- SHELL=sh TEST_SUITE=slow
|
||||
- SHELL=sh TEST_SUITE=slow WITHOUT_CURL=1
|
||||
- SHELL=dash TEST_SUITE=slow
|
||||
- SHELL=dash TEST_SUITE=slow WITHOUT_CURL=1
|
||||
- SHELL=bash TEST_SUITE=slow
|
||||
- SHELL=bash TEST_SUITE=slow WITHOUT_CURL=1
|
||||
- SHELL=zsh TEST_SUITE=slow
|
||||
- SHELL=zsh TEST_SUITE=slow WITHOUT_CURL=1
|
||||
|
@@ -5,7 +5,7 @@ We love pull requests, they're our favorite.
|
||||
However, before submitting, please review the following:
|
||||
|
||||
- Please include tests. Changes with tests will be merged very quickly.
|
||||
- Please manually confirm that your changes, and all tests, pass in `bash`, `sh`, and `zsh`. We hope to soon automatically run all these tests, but in the meantime, we have to rely on each contributor doing so.
|
||||
- Please manually confirm that your changes work in `bash`, `sh`/`dash`, `ksh`, and `zsh`. Fast tests do run in these shells, but it's nice to manually verify also.
|
||||
- Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc.
|
||||
- Any time you make a change to your PR, please rebase freshly on top of master. Nobody likes merge commits.
|
||||
|
||||
|
20
Makefile
20
Makefile
@@ -1,16 +1,26 @@
|
||||
URCHIN=`which urchin`
|
||||
SHELLS=sh bash dash ksh zsh
|
||||
TEST_SUITE=fast
|
||||
|
||||
.PHONY: $(SHELLS) test
|
||||
|
||||
fast: $(SHELLS)
|
||||
.PHONY: $(SHELLS) test verify-tag release
|
||||
|
||||
$(SHELLS):
|
||||
@printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@"
|
||||
@$@ $(URCHIN) -f test/fast
|
||||
@$@ $(URCHIN) -f test/$(TEST_SUITE)
|
||||
|
||||
test: fast
|
||||
test: $(SHELLS)
|
||||
@$(URCHIN) -f test/slow
|
||||
|
||||
default: test
|
||||
|
||||
verify-tag:
|
||||
ifndef TAG
|
||||
$(error TAG is undefined)
|
||||
endif
|
||||
|
||||
release: verify-tag
|
||||
@ OLD_TAG=`git describe --abbrev=0 --tags` && \
|
||||
replace "$${OLD_TAG/v/}" "$(TAG)" -- nvm.sh install.sh README.markdown package.json && \
|
||||
git commit -m "v$(TAG)" nvm.sh install.sh README.markdown package.json && \
|
||||
git tag "v$(TAG)"
|
||||
|
||||
|
@@ -8,17 +8,17 @@ 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.5.1/install.sh | sh
|
||||
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.0/install.sh | bash
|
||||
|
||||
or Wget:
|
||||
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.5.1/install.sh | sh
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.16.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>
|
||||
|
||||
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR` and `NVM_PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm sh` for a global install.
|
||||
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR` and `PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
|
||||
|
||||
<sub>*NB. The installer can use Git, cURL or Wget to download NVM, whatever is available.*</sub>
|
||||
<sub>*NB. The installer can use Git, curl, or wget to download NVM, whatever is available.*</sub>
|
||||
|
||||
### Manual install
|
||||
|
||||
@@ -37,6 +37,9 @@ 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`, `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:
|
||||
|
||||
nvm install 0.10
|
||||
@@ -45,13 +48,13 @@ And then in any new shell just use the installed version:
|
||||
|
||||
nvm use 0.10
|
||||
|
||||
You can create an `.nvmrc` file containing version number in the project root folder; run the following command to switch versions:
|
||||
|
||||
nvm use
|
||||
|
||||
Or you can just run it:
|
||||
|
||||
nvm run 0.10
|
||||
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:
|
||||
|
||||
@@ -76,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.
|
||||
@@ -133,17 +138,17 @@ nvm alias
|
||||
default
|
||||
|
||||
$ nvm alias my_alias [tab][tab]
|
||||
v0.4.11 v0.4.12 v0.6.14
|
||||
v0.6.21 v0.8.26 v0.10.28
|
||||
|
||||
nvm use
|
||||
|
||||
$ nvm use [tab][tab]
|
||||
my_alias default v0.4.11 v0.4.12 v0.6.14
|
||||
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||
|
||||
nvm uninstall
|
||||
|
||||
$ nvm uninstall [tab][tab]
|
||||
my_alias default v0.4.11 v0.4.12 v0.6.14
|
||||
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||
|
||||
## Problems
|
||||
|
||||
@@ -164,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.5.1/install.sh
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.16.0/install.sh
|
||||
[3]: https://travis-ci.org/creationix/nvm
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
|
||||
|
81
install.sh
81
install.sh
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
has() {
|
||||
nvm_has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
@@ -11,41 +11,45 @@ if [ -z "$NVM_DIR" ]; then
|
||||
NVM_DIR="$HOME/.nvm"
|
||||
fi
|
||||
|
||||
if ! has "curl"; then
|
||||
if has "wget"; then
|
||||
nvm_download() {
|
||||
if nvm_has "curl"; then
|
||||
curl $*
|
||||
elif nvm_has "wget"; then
|
||||
# Emulate curl with wget
|
||||
curl() {
|
||||
ARGS="$* "
|
||||
ARGS=${ARGS/-s /-q }
|
||||
ARGS=${ARGS/-o /-O }
|
||||
wget $ARGS
|
||||
}
|
||||
ARGS=$(echo "$*" | sed -e 's/--progress-bar /--progress=bar /' \
|
||||
-e 's/-L //' \
|
||||
-e 's/-I /--server-response /' \
|
||||
-e 's/-s /-q /' \
|
||||
-e 's/-o /-O /' \
|
||||
-e 's/-C - /-c /')
|
||||
wget $ARGS
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
install_from_git() {
|
||||
install_nvm_from_git() {
|
||||
if [ -z "$NVM_SOURCE" ]; then
|
||||
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||
fi
|
||||
|
||||
if [ -d "$NVM_DIR/.git" ]; then
|
||||
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
||||
echo -e "\r=> \c"
|
||||
cd "$NVM_DIR" && git pull 2> /dev/null || {
|
||||
echo >&2 "Failed to update nvm, run 'git pull' in $NVM_DIR yourself.."
|
||||
}
|
||||
printf "\r=> "
|
||||
cd "$NVM_DIR" && (git fetch 2> /dev/null || {
|
||||
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
|
||||
})
|
||||
else
|
||||
# Cloning to $NVM_DIR
|
||||
echo "=> Downloading nvm from git to '$NVM_DIR'"
|
||||
echo -e "\r=> \c"
|
||||
printf "\r=> "
|
||||
mkdir -p "$NVM_DIR"
|
||||
git clone "$NVM_SOURCE" "$NVM_DIR"
|
||||
fi
|
||||
cd $NVM_DIR && git checkout v0.16.0 && git branch -D master || true
|
||||
}
|
||||
|
||||
install_as_script() {
|
||||
install_nvm_as_script() {
|
||||
if [ -z "$NVM_SOURCE" ]; then
|
||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh"
|
||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.16.0/nvm.sh"
|
||||
fi
|
||||
|
||||
# Downloading to $NVM_DIR
|
||||
@@ -55,7 +59,7 @@ install_as_script() {
|
||||
else
|
||||
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||
fi
|
||||
curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
|
||||
nvm_download -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
|
||||
echo >&2 "Failed to download '$NVM_SOURCE'.."
|
||||
return 1
|
||||
}
|
||||
@@ -63,28 +67,28 @@ install_as_script() {
|
||||
|
||||
if [ -z "$METHOD" ]; then
|
||||
# Autodetect install method
|
||||
if has "git"; then
|
||||
install_from_git
|
||||
elif has "curl"; then
|
||||
install_as_script
|
||||
if nvm_has "git"; then
|
||||
install_nvm_from_git
|
||||
elif nvm_has "nvm_download"; then
|
||||
install_nvm_as_script
|
||||
else
|
||||
echo >&2 "You need git, curl or wget to install nvm"
|
||||
echo >&2 "You need git, curl, or wget to install nvm"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ "$METHOD" = "git" ]; then
|
||||
if ! has "git"; then
|
||||
if ! nvm_has "git"; then
|
||||
echo >&2 "You need git to install nvm"
|
||||
exit 1
|
||||
fi
|
||||
install_from_git
|
||||
install_nvm_from_git
|
||||
fi
|
||||
if [ "$METHOD" = "script" ]; then
|
||||
if ! has "curl"; then
|
||||
if ! nvm_has "nvm_download"; then
|
||||
echo >&2 "You need curl or wget to install nvm"
|
||||
exit 1
|
||||
fi
|
||||
install_as_script
|
||||
install_nvm_as_script
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -92,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"
|
||||
@@ -101,30 +107,27 @@ if [ -z "$PROFILE" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
SOURCE_STR="[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\" # This loads nvm"
|
||||
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
|
||||
|
||||
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
|
||||
if [ -z $PROFILE ]; then
|
||||
echo "=> Profile not found. Tried ~/.bash_profile ~/.zshrc and ~/.profile."
|
||||
if [ -z "$PROFILE" ]; then
|
||||
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"
|
||||
echo "=> Create it (touch $PROFILE) and run this script again"
|
||||
fi
|
||||
echo " OR"
|
||||
echo "=> Append the following line to the correct file yourself:"
|
||||
echo
|
||||
echo " $SOURCE_STR"
|
||||
echo "=> Append the following lines to the correct file yourself:"
|
||||
printf "$SOURCE_STR"
|
||||
echo
|
||||
else
|
||||
if ! grep -qc 'nvm.sh' $PROFILE; then
|
||||
if ! grep -qc 'nvm.sh' "$PROFILE"; then
|
||||
echo "=> Appending source string to $PROFILE"
|
||||
echo "" >> "$PROFILE"
|
||||
echo $SOURCE_STR >> "$PROFILE"
|
||||
printf "$SOURCE_STR\n" >> "$PROFILE"
|
||||
else
|
||||
echo "=> Source string already in $PROFILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "=> Close and reopen your terminal to start using nvm"
|
||||
|
||||
|
4
nvm-exec
4
nvm-exec
@@ -5,9 +5,9 @@ DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source "$DIR/nvm.sh"
|
||||
|
||||
if [ -n "$NODE_VERSION" ]; then
|
||||
nvm use $NODE_VERSION || (echo "NODE_VERSION not set" && exit 127)
|
||||
nvm use $NODE_VERSION > /dev/null || (echo "NODE_VERSION not set" >&2 && exit 127)
|
||||
else
|
||||
nvm use || (echo "No .nvmrc file found" && exit 127)
|
||||
nvm use > /dev/null || (echo "No .nvmrc file found" >&2 && exit 127)
|
||||
fi
|
||||
|
||||
exec $@
|
||||
|
475
nvm.sh
475
nvm.sh
@@ -1,5 +1,6 @@
|
||||
# Node Version Manager
|
||||
# Implemented as a bash function
|
||||
# Implemented as a POSIX-compliant function
|
||||
# Should work on sh, dash, bash, ksh, zsh
|
||||
# To use source this file from your bash profile
|
||||
#
|
||||
# Implemented by Tim Caswell <tim@creationix.com>
|
||||
@@ -9,7 +10,25 @@ NVM_SCRIPT_SOURCE="$_"
|
||||
|
||||
nvm_has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
nvm_download() {
|
||||
if nvm_has "curl"; then
|
||||
curl $*
|
||||
elif nvm_has "wget"; then
|
||||
# Emulate curl with wget
|
||||
ARGS=$(echo "$*" | sed -e 's/--progress-bar /--progress=bar /' \
|
||||
-e 's/-L //' \
|
||||
-e 's/-I /--server-response /' \
|
||||
-e 's/-s /-q /' \
|
||||
-e 's/-o /-O /' \
|
||||
-e 's/-C - /-c /')
|
||||
eval wget $ARGS
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_has_system_node() {
|
||||
[ "$(nvm deactivate 2> /dev/null && command -v node)" != '' ]
|
||||
}
|
||||
|
||||
# Make zsh glob matching behave same as bash
|
||||
@@ -34,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
|
||||
@@ -46,7 +84,8 @@ nvm_find_up() {
|
||||
|
||||
|
||||
nvm_find_nvmrc() {
|
||||
local dir="$(nvm_find_up '.nvmrc')"
|
||||
local dir
|
||||
dir="$(nvm_find_up '.nvmrc')"
|
||||
if [ -e "$dir/.nvmrc" ]; then
|
||||
echo "$dir/.nvmrc"
|
||||
fi
|
||||
@@ -54,61 +93,137 @@ nvm_find_nvmrc() {
|
||||
|
||||
# Obtain nvm version from rc file
|
||||
nvm_rc_version() {
|
||||
local NVMRC_PATH="$(nvm_find_nvmrc)"
|
||||
local NVMRC_PATH
|
||||
NVMRC_PATH="$(nvm_find_nvmrc)"
|
||||
if [ -e "$NVMRC_PATH" ]; then
|
||||
NVM_RC_VERSION=`cat "$NVMRC_PATH" | head -n 1`
|
||||
read NVM_RC_VERSION < "$NVMRC_PATH"
|
||||
echo "Found '$NVMRC_PATH' with version <$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=$1
|
||||
local PATTERN
|
||||
PATTERN=$1
|
||||
local VERSION
|
||||
# The default version is the current one
|
||||
if [ -z "$PATTERN" ]; then
|
||||
PATTERN='current'
|
||||
fi
|
||||
|
||||
if [ "$PATTERN" = "current" ]; then
|
||||
nvm_ls_current
|
||||
return $?
|
||||
fi
|
||||
|
||||
VERSION=`nvm_ls $PATTERN | tail -n1`
|
||||
echo "$VERSION"
|
||||
|
||||
if [ "$VERSION" = 'N/A' ]; then
|
||||
return
|
||||
return 3
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_remote_version() {
|
||||
local PATTERN=$1
|
||||
local PATTERN
|
||||
PATTERN=$1
|
||||
local VERSION
|
||||
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
|
||||
echo "$VERSION"
|
||||
|
||||
if [ "$VERSION" = 'N/A' ]; then
|
||||
return
|
||||
return 3
|
||||
fi
|
||||
}
|
||||
|
||||
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() {
|
||||
echo "$1" | sed -e 's/^\([0-9]\)/v\1/g'
|
||||
}
|
||||
|
||||
nvm_strip_path() {
|
||||
echo "$1" | sed -e "s#$NVM_DIR/[^/]*$2[^:]*:##g" -e "s#:$NVM_DIR/[^/]*$2[^:]*##g" -e "s#$NVM_DIR/[^/]*$2[^:]*##g"
|
||||
}
|
||||
|
||||
nvm_prepend_path() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "$2"
|
||||
else
|
||||
echo "$2:$1"
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_binary_available() {
|
||||
# binaries started with node 0.8.6
|
||||
local MINIMAL="0.8.6"
|
||||
local VERSION=$1
|
||||
local MINIMAL
|
||||
MINIMAL="0.8.6"
|
||||
local VERSION
|
||||
VERSION=$1
|
||||
[ $(nvm_normalize_version $VERSION) -ge $(nvm_normalize_version $MINIMAL) ]
|
||||
}
|
||||
|
||||
nvm_ls_current() {
|
||||
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() {
|
||||
local PATTERN=$1
|
||||
local VERSIONS=''
|
||||
local PATTERN
|
||||
PATTERN=$1
|
||||
local VERSIONS
|
||||
VERSIONS=''
|
||||
if [ "$PATTERN" = 'current' ]; then
|
||||
echo `node -v 2>/dev/null`
|
||||
nvm_ls_current
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -117,48 +232,71 @@ nvm_ls() {
|
||||
return
|
||||
fi
|
||||
# If it looks like an explicit version, don't do anything funny
|
||||
if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then
|
||||
VERSIONS="$PATTERN"
|
||||
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then
|
||||
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
|
||||
VERSIONS="$PATTERN"
|
||||
fi
|
||||
else
|
||||
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$(nvm_format_version $PATTERN)*" -exec basename '{}' ';' \
|
||||
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
||||
PATTERN=$(nvm_format_version $PATTERN)
|
||||
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*$"` != 0 ]; then
|
||||
PATTERN="$PATTERN."
|
||||
fi
|
||||
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
|
||||
echo "N/A"
|
||||
return 3
|
||||
fi
|
||||
|
||||
echo "$VERSIONS"
|
||||
return
|
||||
}
|
||||
|
||||
nvm_ls_remote() {
|
||||
local PATTERN=$1
|
||||
local PATTERN
|
||||
PATTERN=$1
|
||||
local VERSIONS
|
||||
local GREP_OPTIONS=''
|
||||
local GREP_OPTIONS
|
||||
GREP_OPTIONS=''
|
||||
if [ -n "$PATTERN" ]; then
|
||||
PATTERN=`nvm_format_version "$PATTERN"`
|
||||
else
|
||||
PATTERN=".*"
|
||||
fi
|
||||
VERSIONS=`curl -s $NVM_NODEJS_ORG_MIRROR/ \
|
||||
VERSIONS=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/ -o - \
|
||||
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
|
||||
| \grep -w "${PATTERN}" \
|
||||
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
||||
if [ -z "$VERSIONS" ]; then
|
||||
echo "N/A"
|
||||
return
|
||||
return 3
|
||||
fi
|
||||
echo "$VERSIONS"
|
||||
return
|
||||
}
|
||||
|
||||
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
|
||||
@@ -167,7 +305,7 @@ nvm_checksum() {
|
||||
echo 'Checksums empty' #missing in raspberry pi binary
|
||||
return
|
||||
else
|
||||
echo 'Checksums do not match.'
|
||||
echo 'Checksums do not match.' >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@@ -175,12 +313,15 @@ nvm_checksum() {
|
||||
nvm_print_versions() {
|
||||
local VERSION
|
||||
local FORMAT
|
||||
local CURRENT=`nvm_version current`
|
||||
local NVM_CURRENT
|
||||
NVM_CURRENT=$(nvm_ls_current)
|
||||
echo "$1" | while read VERSION; do
|
||||
if [ "$VERSION" = "$CURRENT" ]; then
|
||||
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
|
||||
@@ -195,10 +336,13 @@ nvm() {
|
||||
fi
|
||||
|
||||
# Try to figure out the os and arch for binary fetching
|
||||
local uname="$(uname -a)"
|
||||
local os=
|
||||
local arch="$(uname -m)"
|
||||
local GREP_OPTIONS=''
|
||||
local uname
|
||||
uname="$(uname -a)"
|
||||
local os
|
||||
local arch
|
||||
arch="$(uname -m)"
|
||||
local GREP_OPTIONS
|
||||
GREP_OPTIONS=''
|
||||
case "$uname" in
|
||||
Linux\ *) os=linux ;;
|
||||
Darwin\ *) os=darwin ;;
|
||||
@@ -237,6 +381,7 @@ nvm() {
|
||||
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
||||
echo " nvm unalias <name> Deletes the alias named <name>"
|
||||
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
|
||||
echo " nvm unload Unload NVM from shell"
|
||||
echo
|
||||
echo "Example:"
|
||||
echo " nvm install v0.10.24 Install a specific version number"
|
||||
@@ -245,11 +390,11 @@ nvm() {
|
||||
echo " nvm alias default 0.10.24 Set default node version on a shell"
|
||||
echo
|
||||
echo "Note:"
|
||||
echo " to remove, delete or uninstall nvm - just remove ~/.nvm, ~/.npm and ~/.bower folders"
|
||||
echo " to remove, delete, or uninstall nvm - just remove ~/.nvm, ~/.npm, and ~/.bower folders"
|
||||
echo
|
||||
;;
|
||||
|
||||
"install" )
|
||||
"install" | "i" )
|
||||
# initialize local variables
|
||||
local binavail
|
||||
local t
|
||||
@@ -257,11 +402,12 @@ nvm() {
|
||||
local sum
|
||||
local tarball
|
||||
local nobinary
|
||||
local version_not_provided=0
|
||||
local version_not_provided
|
||||
version_not_provided=0
|
||||
local provided_version
|
||||
|
||||
if ! nvm_has "curl"; then
|
||||
echo 'NVM Needs curl to proceed.' >&2;
|
||||
if ! nvm_has "curl" && ! nvm_has "wget"; then
|
||||
echo 'nvm needs curl or wget to proceed.' >&2;
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -293,7 +439,7 @@ nvm() {
|
||||
fi
|
||||
provided_version="$NVM_RC_VERSION"
|
||||
fi
|
||||
[ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." && return
|
||||
[ -d "$(nvm_version_path "$provided_version")" ] && echo "$provided_version is already installed." >&2 && return
|
||||
|
||||
VERSION=`nvm_remote_version $provided_version`
|
||||
ADDITIONAL_PARAMETERS=''
|
||||
@@ -306,7 +452,16 @@ nvm() {
|
||||
shift
|
||||
done
|
||||
|
||||
[ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return
|
||||
if [ -d "$(nvm_version_path "$VERSION")" ]; then
|
||||
echo "$VERSION is already installed." >&2
|
||||
nvm use "$VERSION"
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [ "$VERSION" = "N/A" ]; then
|
||||
echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." >&2
|
||||
return 3
|
||||
fi
|
||||
|
||||
# skip binary install if no binary option specified.
|
||||
if [ $nobinary -ne 1 ]; then
|
||||
@@ -315,20 +470,22 @@ nvm() {
|
||||
if nvm_binary_available "$VERSION"; then
|
||||
t="$VERSION-$os-$arch"
|
||||
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
|
||||
sum=`curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt | \grep node-${t}.tar.gz | awk '{print $1}'`
|
||||
local tmpdir="$NVM_DIR/bin/node-${t}"
|
||||
local tmptarball="$tmpdir/node-${t}.tar.gz"
|
||||
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
|
||||
tmptarball="$tmpdir/node-${t}.tar.gz"
|
||||
if (
|
||||
mkdir -p "$tmpdir" && \
|
||||
curl -L -C - --progress-bar $url -o "$tmptarball" && \
|
||||
nvm_download -L -C - --progress-bar $url -o "$tmptarball" && \
|
||||
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
|
||||
return;
|
||||
return $?
|
||||
else
|
||||
echo "Binary download failed, trying source." >&2
|
||||
rm -rf "$tmptarball" "$tmpdir"
|
||||
@@ -346,24 +503,26 @@ nvm() {
|
||||
make='gmake'
|
||||
MAKE_CXX="CXX=c++"
|
||||
fi
|
||||
local tmpdir="$NVM_DIR/src"
|
||||
local tmptarball="$tmpdir/node-$VERSION.tar.gz"
|
||||
if [ "`curl -Is "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
|
||||
local tmpdir
|
||||
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 - 2>&1 | \grep '200 OK'`" != '' ]; then
|
||||
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
|
||||
sum=`curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt | \grep node-$VERSION.tar.gz | awk '{print $1}'`
|
||||
elif [ "`curl -Is "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
|
||||
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
|
||||
if (
|
||||
[ -n "$tarball" ] && \
|
||||
mkdir -p "$tmpdir" && \
|
||||
curl -L --progress-bar $tarball -o "$tmptarball" && \
|
||||
nvm_download -L --progress-bar $tarball -o "$tmptarball" && \
|
||||
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
|
||||
@@ -371,19 +530,19 @@ nvm() {
|
||||
if ! nvm_has "npm" ; then
|
||||
echo "Installing npm..."
|
||||
if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then
|
||||
echo "npm requires node v0.2.3 or higher"
|
||||
echo "npm requires node v0.2.3 or higher" >&2
|
||||
elif [ "`expr "$VERSION" : '\(^v0\.2\.\)'`" != '' ]; then
|
||||
if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then
|
||||
echo "npm requires node v0.2.3 or higher"
|
||||
echo "npm requires node v0.2.3 or higher" >&2
|
||||
else
|
||||
curl https://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh
|
||||
nvm_download https://npmjs.org/install.sh -o - | clean=yes npm_install=0.2.19 sh
|
||||
fi
|
||||
else
|
||||
curl https://npmjs.org/install.sh | clean=yes sh
|
||||
nvm_download https://npmjs.org/install.sh -o - | clean=yes sh
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "nvm: install $VERSION failed!"
|
||||
echo "nvm: install $VERSION failed!" >&2
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
@@ -391,12 +550,12 @@ nvm() {
|
||||
[ $# -ne 2 ] && nvm help && return
|
||||
PATTERN=`nvm_format_version $2`
|
||||
if [ "$PATTERN" = `nvm_version` ]; then
|
||||
echo "nvm: Cannot uninstall currently-active node version, $PATTERN."
|
||||
echo "nvm: Cannot uninstall currently-active node version, $PATTERN." >&2
|
||||
return 1
|
||||
fi
|
||||
VERSION=`nvm_version $PATTERN`
|
||||
if [ ! -d $NVM_DIR/$VERSION ]; then
|
||||
echo "$VERSION version is not installed..."
|
||||
if [ ! -d "$(nvm_version_path "$VERSION")" ]; then
|
||||
echo "$VERSION version is not installed..." >&2
|
||||
return;
|
||||
fi
|
||||
|
||||
@@ -407,7 +566,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.
|
||||
@@ -419,23 +578,23 @@ nvm() {
|
||||
;;
|
||||
"deactivate" )
|
||||
if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin.*"` != 0 ] ; then
|
||||
export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:}
|
||||
export PATH=`nvm_strip_path "$PATH" "/bin"`
|
||||
hash -r
|
||||
echo "$NVM_DIR/*/bin removed from \$PATH"
|
||||
else
|
||||
echo "Could not find $NVM_DIR/*/bin in \$PATH"
|
||||
echo "Could not find $NVM_DIR/*/bin in \$PATH" >&2
|
||||
fi
|
||||
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then
|
||||
export MANPATH=${MANPATH%$NVM_DIR/*/share/man*}${MANPATH#*$NVM_DIR/*/share/man:}
|
||||
export MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
|
||||
echo "$NVM_DIR/*/share/man removed from \$MANPATH"
|
||||
else
|
||||
echo "Could not find $NVM_DIR/*/share/man in \$MANPATH"
|
||||
echo "Could not find $NVM_DIR/*/share/man in \$MANPATH" >&2
|
||||
fi
|
||||
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ] ; then
|
||||
export NODE_PATH=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}${NODE_PATH#*$NVM_DIR/*/lib/node_modules:}
|
||||
export NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
|
||||
else
|
||||
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH"
|
||||
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH" >&2
|
||||
fi
|
||||
;;
|
||||
"use" )
|
||||
@@ -446,10 +605,20 @@ nvm() {
|
||||
if [ $# -eq 1 ]; then
|
||||
nvm_rc_version
|
||||
if [ -n "$NVM_RC_VERSION" ]; then
|
||||
VERSION=`nvm_version $NVM_RC_VERSION`
|
||||
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
|
||||
@@ -458,40 +627,42 @@ nvm() {
|
||||
if [ -z "$VERSION" ]; then
|
||||
VERSION=`nvm_version $2`
|
||||
fi
|
||||
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
||||
echo "$VERSION version is not installed yet"
|
||||
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
|
||||
if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin"` != 0 ]; then
|
||||
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin}
|
||||
else
|
||||
PATH="$NVM_DIR/$VERSION/bin:$PATH"
|
||||
fi
|
||||
# Strip other version from PATH
|
||||
PATH=`nvm_strip_path "$PATH" "/bin"`
|
||||
# Prepend current version
|
||||
PATH=`nvm_prepend_path "$PATH" "$NVM_VERSION_DIR/bin"`
|
||||
if [ -z "$MANPATH" ]; then
|
||||
MANPATH=$(manpath)
|
||||
fi
|
||||
MANPATH=${MANPATH#*$NVM_DIR/*/man:}
|
||||
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man"` != 0 ]; then
|
||||
MANPATH=${MANPATH%$NVM_DIR/*/share/man*}$NVM_DIR/$VERSION/share/man${MANPATH#*$NVM_DIR/*/share/man}
|
||||
else
|
||||
MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"
|
||||
fi
|
||||
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ]; then
|
||||
NODE_PATH=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}$NVM_DIR/$VERSION/lib/node_modules${NODE_PATH#*$NVM_DIR/*/lib/node_modules}
|
||||
else
|
||||
NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
|
||||
fi
|
||||
# Strip other version from MANPATH
|
||||
MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
|
||||
# Prepend current version
|
||||
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_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"
|
||||
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" )
|
||||
local provided_version
|
||||
local has_checked_nvmrc=0
|
||||
local has_checked_nvmrc
|
||||
has_checked_nvmrc=0
|
||||
# run given version of node
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
@@ -521,28 +692,56 @@ nvm() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
||||
echo "$VERSION version is not installed yet"
|
||||
return;
|
||||
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
|
||||
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ]; then
|
||||
RUN_NODE_PATH=${NODE_PATH%$NVM_DIR/*/lib/node_modules*}$NVM_DIR/$VERSION/lib/node_modules${NODE_PATH#*$NVM_DIR/*/lib/node_modules}
|
||||
else
|
||||
RUN_NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"
|
||||
RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/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_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_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
|
||||
NODE_VERSION=$VERSION $NVM_DIR/nvm-exec "$@"
|
||||
;;
|
||||
"ls" | "list" )
|
||||
nvm_print_versions "`nvm_ls $2`"
|
||||
local NVM_LS_OUTPUT
|
||||
local NVM_LS_EXIT_CODE
|
||||
NVM_LS_OUTPUT=$(nvm_ls "$2")
|
||||
NVM_LS_EXIT_CODE=$?
|
||||
nvm_print_versions "$NVM_LS_OUTPUT"
|
||||
if [ $# -eq 1 ]; then
|
||||
nvm alias
|
||||
fi
|
||||
return
|
||||
return $NVM_LS_EXIT_CODE
|
||||
;;
|
||||
"ls-remote" | "list-remote" )
|
||||
nvm_print_versions "`nvm_ls_remote $2`"
|
||||
return
|
||||
nvm_print_versions "`nvm_ls_remote $2`"
|
||||
return
|
||||
;;
|
||||
"current" )
|
||||
nvm_version current
|
||||
@@ -556,18 +755,18 @@ nvm() {
|
||||
DEST=`cat $ALIAS`
|
||||
VERSION=`nvm_version $DEST`
|
||||
if [ "$DEST" = "$VERSION" ]; then
|
||||
echo "$(basename $ALIAS) -> $DEST"
|
||||
echo "$(basename $ALIAS) -> $DEST"
|
||||
else
|
||||
echo "$(basename $ALIAS) -> $DEST (-> $VERSION)"
|
||||
echo "$(basename $ALIAS) -> $DEST (-> $VERSION)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return
|
||||
fi
|
||||
if [ -z "$3" ]; then
|
||||
rm -f $NVM_DIR/alias/$2
|
||||
echo "$2 -> *poof*"
|
||||
return
|
||||
rm -f $NVM_DIR/alias/$2
|
||||
echo "$2 -> *poof*"
|
||||
return
|
||||
fi
|
||||
mkdir -p $NVM_DIR/alias
|
||||
VERSION=`nvm_version $3`
|
||||
@@ -576,7 +775,7 @@ nvm() {
|
||||
fi
|
||||
echo $3 > "$NVM_DIR/alias/$2"
|
||||
if [ ! "$3" = "$VERSION" ]; then
|
||||
echo "$2 -> $3 (-> $VERSION)"
|
||||
echo "$2 -> $3 (-> $VERSION)"
|
||||
else
|
||||
echo "$2 -> $3"
|
||||
fi
|
||||
@@ -584,34 +783,52 @@ nvm() {
|
||||
"unalias" )
|
||||
mkdir -p $NVM_DIR/alias
|
||||
[ $# -ne 2 ] && nvm help && return 127
|
||||
[ ! -f "$NVM_DIR/alias/$2" ] && echo "Alias $2 doesn't exist!" && return
|
||||
[ ! -f "$NVM_DIR/alias/$2" ] && echo "Alias $2 doesn't exist!" >&2 && return
|
||||
rm -f $NVM_DIR/alias/$2
|
||||
echo "Deleted alias $2"
|
||||
;;
|
||||
"copy-packages" )
|
||||
if [ $# -ne 2 ]; then
|
||||
nvm help
|
||||
return 127
|
||||
if [ $# -ne 2 ]; then
|
||||
nvm help
|
||||
return 127
|
||||
fi
|
||||
|
||||
local PROVIDED_VERSION
|
||||
PROVIDED_VERSION="$2"
|
||||
|
||||
if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ]; then
|
||||
echo 'Can not copy packages from the current version of node.' >&2
|
||||
return 2
|
||||
fi
|
||||
|
||||
local INSTALLS
|
||||
if [ "$PROVIDED_VERSION" = "system" ]; then
|
||||
if ! nvm_has_system_node; then
|
||||
echo 'No system version of node detected.' >&2
|
||||
return 3
|
||||
fi
|
||||
VERSION=`nvm_version $2`
|
||||
local ROOT=`(nvm use $VERSION && npm -g root)`
|
||||
local ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1))
|
||||
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
|
||||
|
||||
# declare local INSTALLS first, otherwise it doesn't work in zsh
|
||||
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" " "`
|
||||
|
||||
npm install -g ${INSTALLS[@]}
|
||||
echo "$INSTALLS" | xargs npm install -g --quiet
|
||||
;;
|
||||
"clear-cache" )
|
||||
rm -f $NVM_DIR/v* 2>/dev/null
|
||||
echo "Cache cleared."
|
||||
rm -f $NVM_DIR/v* "$(nvm_version_dir)" 2>/dev/null
|
||||
echo "Cache cleared."
|
||||
;;
|
||||
"version" )
|
||||
nvm_version $2
|
||||
nvm_version $2
|
||||
;;
|
||||
"--version" )
|
||||
echo "nvm v0.5.1"
|
||||
echo "0.16.0"
|
||||
;;
|
||||
"unload" )
|
||||
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater > /dev/null 2>&1
|
||||
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
|
||||
;;
|
||||
* )
|
||||
nvm help
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.5.1",
|
||||
"version": "0.16.0",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
|
@@ -2,11 +2,40 @@
|
||||
|
||||
mkdir ../../../v0.1.3
|
||||
mkdir ../../../v0.2.3
|
||||
mkdir ../../../v0.20.3
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
# The result should contain only the appropriate version numbers.
|
||||
nvm ls 0.2 | grep v0.2.3 &&
|
||||
nvm ls 0.1 | grep -v v0.2.3 &&
|
||||
nvm ls 0.1 | grep v0.1.3 &&
|
||||
nvm ls v0.2 | grep v0.2.3
|
||||
|
||||
nvm ls 0.1 | grep 'v0.2.3' > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo '"nvm ls 0.1" contained v0.2.3'
|
||||
fi
|
||||
|
||||
nvm ls 0.1 | grep 'v0.20.3' > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
die '"nvm ls 0.1" contained v0.20.3'
|
||||
fi
|
||||
|
||||
nvm ls 0.1 | grep 'v0.1.3' > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
die '"nvm ls 0.1" did not contain v0.1.3'
|
||||
fi
|
||||
|
||||
nvm ls 0.2 | grep 'v0.2.3' > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
die '"nvm ls 0.2" did not contain v0.2.3'
|
||||
fi
|
||||
|
||||
nvm ls 0.2 | grep 'v0.20.3' > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
die '"nvm ls 0.2" contained v0.20.3'
|
||||
fi
|
||||
|
||||
nvm ls 0.2 | grep 'v0.2.3' > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
die '"nvm ls 0.2" did not contain v0.2.3'
|
||||
fi
|
||||
|
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls nonexistent_version
|
||||
[ "$?" = "3" ]
|
||||
|
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls node
|
||||
[ "$?" = "3" ]
|
||||
|
@@ -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'
|
||||
|
9
test/fast/Listing versions/Running "nvm ls" should filter out ".nvm"
Executable file
9
test/fast/Listing versions/Running "nvm ls" should filter out ".nvm"
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir ../../../v0.1.3
|
||||
mkdir ../../../v0.2.3
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
[ -z `nvm ls | grep '^ *\.'` ]
|
||||
# The result should contain only the appropriate version numbers.
|
14
test/fast/Listing versions/Running "nvm ls" should filter out "versions"
Executable file
14
test/fast/Listing versions/Running "nvm ls" should filter out "versions"
Executable 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
|
||||
|
@@ -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'
|
||||
|
@@ -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'
|
||||
|
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir ../../../v0.1.2
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
nvm ls v0.1 | grep v0.1.2 &&
|
||||
nvm ls v0.1.2 | grep v0.1.2 &&
|
||||
nvm ls v0.1. | grep N/A &&
|
||||
nvm ls v0.1.1 | grep N/A
|
||||
|
12
test/fast/Listing versions/teardown
Normal file
12
test/fast/Listing versions/teardown
Normal file
@@ -0,0 +1,12 @@
|
||||
rmdir ../../../v0.0.1
|
||||
rmdir ../../../v0.0.3
|
||||
rmdir ../../../v0.0.9
|
||||
rmdir ../../../v0.1.2
|
||||
rmdir ../../../v0.1.3
|
||||
rmdir ../../../v0.2.3
|
||||
rmdir ../../../v0.3.1
|
||||
rmdir ../../../v0.3.3
|
||||
rmdir ../../../v0.3.9
|
||||
rmdir ../../../versions
|
||||
unalias nvm_has_system_node
|
||||
|
@@ -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'
|
||||
|
||||
|
@@ -8,7 +8,7 @@ die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
nvm use v0.2.3 &&
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] || die "Failed to activate v0.2.3"
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3"
|
||||
|
||||
nvm deactivate &&
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || die "Failed to deactivate v0.2.3"
|
||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3"
|
||||
|
7
test/fast/Running "nvm install" with an invalid version fails nicely
Executable file
7
test/fast/Running "nvm install" with an invalid version fails nicely
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/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"
|
||||
|
12
test/fast/Running "nvm unload" should unset all function and variables.
Executable file
12
test/fast/Running "nvm unload" should unset all function and variables.
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
fail () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
|
||||
type nvm > /dev/null 2>&1 || fail "NVM not loaded"
|
||||
|
||||
nvm unload
|
||||
|
||||
type nvm > /dev/null 2>&1 && fail "NVM not unloaded" || exit 0
|
||||
|
13
test/fast/Running "nvm use system" should work as expected
Executable file
13
test/fast/Running "nvm use system" should work as expected
Executable 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"
|
||||
|
32
test/fast/Running "nvm use x" should create and change the "current" symlink
Executable file
32
test/fast/Running "nvm use x" should create and change the "current" symlink
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ../../nvm.sh
|
||||
|
||||
rm -rf ../../v0.10.29
|
||||
mkdir ../../v0.10.29
|
||||
nvm use 0.10.29
|
||||
rmdir ../../v0.10.29
|
||||
|
||||
if [ ! -L ../../current ];then
|
||||
echo "Expected 'current' symlink to be created!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
oldLink="$(readlink ../../current)"
|
||||
|
||||
if [ "$(basename $oldLink)" != 'v0.10.29' ];then
|
||||
echo "Expected 'current' to point to v0.10.29 but was $oldLink"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf ../../v0.11.13
|
||||
mkdir ../../v0.11.13
|
||||
nvm use 0.11.13
|
||||
rmdir ../../v0.11.13
|
||||
|
||||
newLink="$(readlink ../../current)"
|
||||
|
||||
if [ "$(basename $newLink)" != 'v0.11.13' ];then
|
||||
echo "Expected 'current' to point to v0.11.13 but was $newLink"
|
||||
exit 1
|
||||
fi
|
@@ -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
|
||||
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
|
18
test/fast/Unit tests/nvm_checksum
Executable file
18
test/fast/Unit tests/nvm_checksum
Executable 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
|
29
test/fast/Unit tests/nvm_has_system_node
Executable file
29
test/fast/Unit tests/nvm_has_system_node
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
rm ../../../v0.1.2/node
|
||||
rmdir ../../../v0.1.2
|
||||
}
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
mkdir ../../../v0.1.2
|
||||
touch ../../../v0.1.2/node
|
||||
|
||||
nvm use 0.1.2
|
||||
|
||||
if command -v node; then
|
||||
nvm_has_system_node
|
||||
else
|
||||
! nvm_has_system_node
|
||||
fi
|
||||
|
||||
nvm deactivate /dev/null 2>&1
|
||||
|
||||
if command -v node; then
|
||||
nvm_has_system_node
|
||||
else
|
||||
! nvm_has_system_node
|
||||
fi
|
||||
|
28
test/fast/Unit tests/nvm_ls_current
Executable file
28
test/fast/Unit tests/nvm_ls_current
Executable 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"
|
||||
|
18
test/fast/Unit tests/nvm_prepend_path
Executable file
18
test/fast/Unit tests/nvm_prepend_path
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
TEST_PATH=/usr/bin:/usr/local/bin
|
||||
|
||||
NEW_PATH=`nvm_prepend_path "$TEST_PATH" "$NVM_DIR/v0.2.5/bin"`
|
||||
|
||||
[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
||||
|
||||
|
||||
EMPTY_PATH=
|
||||
|
||||
NEW_PATH=`nvm_prepend_path "$EMPTY_PATH" "$NVM_DIR/v0.2.5/bin"`
|
||||
|
||||
[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
11
test/fast/Unit tests/nvm_strip_path
Executable file
11
test/fast/Unit tests/nvm_strip_path
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
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
|
||||
|
||||
STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"`
|
||||
|
||||
[ "$STRIPPED_PATH" = "/usr/bin:/usr/local/bin" ] || die "Not correctly stripped: $STRIPPED_PATH "
|
32
test/fast/Unit tests/nvm_tree_contains_path
Executable file
32
test/fast/Unit tests/nvm_tree_contains_path
Executable 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
|
||||
|
11
test/fast/Unit tests/nvm_version_dir
Executable file
11
test/fast/Unit tests/nvm_version_dir
Executable 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'
|
||||
|
16
test/fast/Unit tests/nvm_version_greater
Executable file
16
test/fast/Unit tests/nvm_version_greater
Executable 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
|
||||
|
11
test/fast/Unit tests/nvm_version_path
Executable file
11
test/fast/Unit tests/nvm_version_path
Executable 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'
|
||||
|
@@ -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
|
||||
)
|
||||
|
14
test/slow/Running "nvm current" should display current nvm environment.
Executable file
14
test/slow/Running "nvm current" should display current nvm environment.
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
|
||||
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"
|
||||
|
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../nvm.sh
|
||||
|
||||
local EXPECTED_MSG="Can not copy packages from the current version of node."
|
||||
[ "$(nvm use 0.10.28 && nvm copy-packages 0.10.28 2&>1)" = "$EXPECTED_MSG" ] || die '"nvm use 0.10.28 && nvm copy-packages 0.10.28" did not fail with the right message'
|
||||
|
||||
$(nvm use 0.10.28 && nvm copy-packages 0.10.28)
|
||||
[ $? = 2 ] || die '"nvm use 0.10.28 && nvm copy-packages 0.10.28" did not fail with the right error code'
|
||||
|
10
test/slow/nvm copy-packages/setup_dir
Executable file
10
test/slow/nvm copy-packages/setup_dir
Executable 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
|
||||
|
21
test/slow/nvm copy-packages/should work as expected
Executable file
21
test/slow/nvm copy-packages/should work as expected
Executable 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)"
|
||||
|
12
test/slow/nvm copy-packages/teardown_dir
Executable file
12
test/slow/nvm copy-packages/teardown_dir
Executable 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
|
||||
|
13
test/slow/nvm exec/Running "nvm exec 0.x" should work
Executable file
13
test/slow/nvm exec/Running "nvm exec 0.x" should work
Executable 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"
|
||||
|
17
test/slow/nvm exec/Running "nvm exec" should pick up .nvmrc version
Executable file
17
test/slow/nvm exec/Running "nvm exec" should pick up .nvmrc version
Executable 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
10
test/slow/nvm exec/setup_dir
Executable 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
12
test/slow/nvm exec/teardown_dir
Executable 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
|
||||
|
24
test/slow/nvm install/install already installed uses it
Executable file
24
test/slow/nvm install/install already installed uses it
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/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 ../../../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 install 0.9.12
|
||||
|
||||
nvm use 0.9.7
|
||||
|
||||
node --version | grep v0.9.7 || die "precondition failed: node doesn't start at 0.9.7"
|
||||
|
||||
nvm install 0.9.12
|
||||
|
||||
node --version | grep v0.9.12 || die "nvm install on already installed version doesn't use it"
|
||||
|
@@ -9,7 +9,7 @@ set -e
|
||||
|
||||
# Install from binary
|
||||
nvm install 0.9.7
|
||||
nvm install 0.9.12
|
||||
nvm i 0.9.12
|
||||
|
||||
# Check
|
||||
[ -d ../../../v0.9.7 ]
|
||||
|
Reference in New Issue
Block a user