Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64de890d07 | ||
|
|
a4da8a48ef | ||
|
|
354be52672 | ||
|
|
ad604cc068 | ||
|
|
ba08fa31d8 | ||
|
|
13aadbcf31 | ||
|
|
7bb6e9c915 | ||
|
|
3d3145f2e0 | ||
|
|
4c948cf422 | ||
|
|
f8054d5cae | ||
|
|
ad2713b13a | ||
|
|
243fc04164 | ||
|
|
a80f958a1e | ||
|
|
f6fef75f36 | ||
|
|
199ba53340 | ||
|
|
d1b6332bbe | ||
|
|
159d4c645e | ||
|
|
687df82107 | ||
|
|
ff1781b95d | ||
|
|
110e571c34 | ||
|
|
a7108e98f2 | ||
|
|
30b044a368 | ||
|
|
825cb46969 | ||
|
|
ab56ec6675 | ||
|
|
9d96e4a6bf | ||
|
|
a00a3a7429 | ||
|
|
1c3585e5a2 | ||
|
|
214ce8853b | ||
|
|
d24dc662dc | ||
|
|
e8056ac460 | ||
|
|
429656bc41 | ||
|
|
b61445cbf4 | ||
|
|
603253b0cb | ||
|
|
5ee955bb62 | ||
|
|
83a0efb085 | ||
|
|
9306a9b3f0 | ||
|
|
59939d09e8 | ||
|
|
814319d7c0 | ||
|
|
4b3d6f1760 | ||
|
|
56c40cfa3c |
20
.travis.yml
20
.travis.yml
@@ -10,20 +10,22 @@ script:
|
|||||||
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin $SHELL
|
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin $SHELL
|
||||||
env:
|
env:
|
||||||
- SHELL=sh TEST_SUITE=fast
|
- SHELL=sh TEST_SUITE=fast
|
||||||
- SHELL=sh TEST_SUITE=fast WITHOUT_CURL=1
|
|
||||||
- SHELL=dash TEST_SUITE=fast
|
- SHELL=dash TEST_SUITE=fast
|
||||||
- SHELL=dash TEST_SUITE=fast WITHOUT_CURL=1
|
|
||||||
- SHELL=bash TEST_SUITE=fast
|
- SHELL=bash TEST_SUITE=fast
|
||||||
- SHELL=bash TEST_SUITE=fast WITHOUT_CURL=1
|
|
||||||
- SHELL=zsh TEST_SUITE=fast
|
- SHELL=zsh TEST_SUITE=fast
|
||||||
- SHELL=zsh TEST_SUITE=fast WITHOUT_CURL=1
|
|
||||||
- SHELL=ksh TEST_SUITE=fast
|
- SHELL=ksh TEST_SUITE=fast
|
||||||
- SHELL=ksh TEST_SUITE=fast WITHOUT_CURL=1
|
|
||||||
- SHELL=sh TEST_SUITE=slow
|
- SHELL=sh TEST_SUITE=slow
|
||||||
- SHELL=sh TEST_SUITE=slow WITHOUT_CURL=1
|
|
||||||
- SHELL=dash TEST_SUITE=slow
|
- SHELL=dash TEST_SUITE=slow
|
||||||
- SHELL=dash TEST_SUITE=slow WITHOUT_CURL=1
|
|
||||||
- SHELL=bash TEST_SUITE=slow
|
- SHELL=bash TEST_SUITE=slow
|
||||||
- SHELL=bash TEST_SUITE=slow WITHOUT_CURL=1
|
|
||||||
- SHELL=zsh TEST_SUITE=slow
|
- SHELL=zsh TEST_SUITE=slow
|
||||||
- SHELL=zsh TEST_SUITE=slow WITHOUT_CURL=1
|
- 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
|
||||||
|
|||||||
@@ -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:
|
To install you could use the [install script][2] using cURL:
|
||||||
|
|
||||||
curl https://raw.githubusercontent.com/creationix/nvm/v0.14.0/install.sh | bash
|
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | bash
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.14.0/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>
|
<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`.
|
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:
|
To activate nvm, you need to source it from your shell:
|
||||||
|
|
||||||
@@ -79,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_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
|
## License
|
||||||
|
|
||||||
nvm is released under the MIT license.
|
nvm is released under the MIT license.
|
||||||
@@ -167,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
|
nvm install -s 0.8.6
|
||||||
|
|
||||||
[1]: https://github.com/creationix/nvm.git
|
[1]: https://github.com/creationix/nvm.git
|
||||||
[2]: https://github.com/creationix/nvm/blob/v0.14.0/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.16.1/install.sh
|
||||||
[3]: https://travis-ci.org/creationix/nvm
|
[3]: https://travis-ci.org/creationix/nvm
|
||||||
[Urchin]: https://github.com/scraperwiki/urchin
|
[Urchin]: https://github.com/scraperwiki/urchin
|
||||||
|
|
||||||
|
|||||||
10
install.sh
10
install.sh
@@ -44,12 +44,12 @@ install_nvm_from_git() {
|
|||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
git clone "$NVM_SOURCE" "$NVM_DIR"
|
git clone "$NVM_SOURCE" "$NVM_DIR"
|
||||||
fi
|
fi
|
||||||
cd $NVM_DIR && git checkout v0.14.0 && git branch -D master || true
|
cd $NVM_DIR && git checkout v0.16.1 && git branch -D master || true
|
||||||
}
|
}
|
||||||
|
|
||||||
install_nvm_as_script() {
|
install_nvm_as_script() {
|
||||||
if [ -z "$NVM_SOURCE" ]; then
|
if [ -z "$NVM_SOURCE" ]; then
|
||||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.14.0/nvm.sh"
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.16.1/nvm.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Downloading to $NVM_DIR
|
# Downloading to $NVM_DIR
|
||||||
@@ -96,7 +96,9 @@ echo
|
|||||||
|
|
||||||
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile).
|
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile).
|
||||||
if [ -z "$PROFILE" ]; then
|
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"
|
PROFILE="$HOME/.bash_profile"
|
||||||
elif [ -f "$HOME/.zshrc" ]; then
|
elif [ -f "$HOME/.zshrc" ]; then
|
||||||
PROFILE="$HOME/.zshrc"
|
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" ] || [ ! -f "$PROFILE" ] ; then
|
||||||
if [ -z "$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"
|
echo "=> Create one of them and run this script again"
|
||||||
else
|
else
|
||||||
echo "=> Profile $PROFILE not found"
|
echo "=> Profile $PROFILE not found"
|
||||||
|
|||||||
60
nvm.sh
60
nvm.sh
@@ -249,13 +249,20 @@ nvm_ls() {
|
|||||||
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.' | \grep -e '^v'`
|
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.' | \grep -e '^v'`
|
||||||
fi
|
fi
|
||||||
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
|
if [ -z "$VERSIONS" ]; then
|
||||||
echo "N/A"
|
echo "N/A"
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
if [ -z "$PATTERN" ] && nvm_has_system_node; then
|
|
||||||
VERSIONS="$VERSIONS$(printf '\n%s' 'system')"
|
|
||||||
fi
|
|
||||||
echo "$VERSIONS"
|
echo "$VERSIONS"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -284,12 +291,12 @@ nvm_ls_remote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nvm_checksum() {
|
nvm_checksum() {
|
||||||
if nvm_has "shasum"; then
|
if nvm_has "sha1sum"; then
|
||||||
checksum=$(shasum $1 | \awk '{print $1}')
|
checksum=$(sha1sum $1 | \awk '{print $1}')
|
||||||
elif nvm_has "sha1"; then
|
elif nvm_has "sha1"; then
|
||||||
checksum=$(sha1 -q $1)
|
checksum=$(sha1 -q $1)
|
||||||
else
|
else
|
||||||
checksum=$(sha1sum $1 | \awk '{print $1}')
|
checksum=$(shasum $1 | \awk '{print $1}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$checksum" = "$2" ]; then
|
if [ "$checksum" = "$2" ]; then
|
||||||
@@ -426,19 +433,20 @@ nvm() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
provided_version=$1
|
provided_version=$1
|
||||||
|
|
||||||
if [ -z "$provided_version" ]; then
|
if [ -z "$provided_version" ]; then
|
||||||
if [ $version_not_provided -ne 1 ]; then
|
if [ $version_not_provided -ne 1 ]; then
|
||||||
nvm_rc_version
|
nvm_rc_version
|
||||||
fi
|
fi
|
||||||
provided_version="$NVM_RC_VERSION"
|
provided_version="$NVM_RC_VERSION"
|
||||||
|
else
|
||||||
|
shift
|
||||||
fi
|
fi
|
||||||
[ -d "$(nvm_version_path "$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`
|
VERSION=`nvm_remote_version $provided_version`
|
||||||
ADDITIONAL_PARAMETERS=''
|
ADDITIONAL_PARAMETERS=''
|
||||||
|
|
||||||
shift
|
|
||||||
|
|
||||||
while [ $# -ne 0 ]
|
while [ $# -ne 0 ]
|
||||||
do
|
do
|
||||||
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
|
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
|
||||||
@@ -487,7 +495,9 @@ nvm() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
|
if [ -n "$ADDITIONAL_PARAMETERS" ]; then
|
||||||
|
echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
|
||||||
|
fi
|
||||||
|
|
||||||
tarball=''
|
tarball=''
|
||||||
sum=''
|
sum=''
|
||||||
@@ -647,7 +657,9 @@ nvm() {
|
|||||||
export NODE_PATH
|
export NODE_PATH
|
||||||
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
|
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
|
||||||
export NVM_BIN="$NVM_VERSION_DIR/bin"
|
export NVM_BIN="$NVM_VERSION_DIR/bin"
|
||||||
rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
|
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"
|
echo "Now using node $VERSION"
|
||||||
;;
|
;;
|
||||||
"run" )
|
"run" )
|
||||||
@@ -783,15 +795,29 @@ nvm() {
|
|||||||
nvm help
|
nvm help
|
||||||
return 127
|
return 127
|
||||||
fi
|
fi
|
||||||
VERSION=$(nvm_version "$2")
|
|
||||||
local ROOT
|
|
||||||
ROOT=$(nvm use $VERSION && npm -g root)
|
|
||||||
|
|
||||||
# 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
|
local INSTALLS
|
||||||
INSTALLS=$(nvm use $VERSION > /dev/null && npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | \grep -o -e '/[^/]*$' | cut -c 2- | xargs)
|
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 --quiet $INSTALLS
|
echo "$INSTALLS" | xargs npm install -g --quiet
|
||||||
;;
|
;;
|
||||||
"clear-cache" )
|
"clear-cache" )
|
||||||
rm -f $NVM_DIR/v* "$(nvm_version_dir)" 2>/dev/null
|
rm -f $NVM_DIR/v* "$(nvm_version_dir)" 2>/dev/null
|
||||||
@@ -801,7 +827,7 @@ nvm() {
|
|||||||
nvm_version $2
|
nvm_version $2
|
||||||
;;
|
;;
|
||||||
"--version" )
|
"--version" )
|
||||||
echo "0.14.0"
|
echo "0.16.1"
|
||||||
;;
|
;;
|
||||||
"unload" )
|
"unload" )
|
||||||
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater > /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
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.14.0",
|
"version": "0.16.1",
|
||||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
@@ -8,7 +8,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "urchin test",
|
"test": "urchin test",
|
||||||
"test/fast": "urchin -f test/fast",
|
"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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|
||||||
0
test/fast/Listing versions/teardown
Normal file → Executable file
0
test/fast/Listing versions/teardown
Normal file → Executable 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
|
||||||
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
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
die () { echo $@ ; exit 1; }
|
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"
|
[ "$(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.
|
# Remove the stuff we're clobbering.
|
||||||
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
|
[ -e ../../v0.9.7 ] && rm -R ../../v0.9.7
|
||||||
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
|
[ -e ../../v0.9.12 ] && rm -R ../../v0.9.12
|
||||||
|
|
||||||
# Install from binary
|
# Install from binary
|
||||||
nvm install 0.9.7
|
nvm install 0.9.7
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
. ../../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# 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
|
# Install from binary
|
||||||
nvm install $NVM_TEST_VERSION
|
nvm install $NVM_TEST_VERSION
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
[ -d ../../$NVM_TEST_VERSION ]
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||||
|
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
. ../../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# 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
|
# Install from source
|
||||||
nvm install -s $NVM_TEST_VERSION
|
nvm install -s $NVM_TEST_VERSION
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
[ -d ../../$NVM_TEST_VERSION ]
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||||
|
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
. ../../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# Remove the stuff we're clobbering.
|
||||||
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
|
[ -e ../../v0.9.7 ] && rm -R ../../v0.9.7
|
||||||
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
|
[ -e ../../v0.9.12 ] && rm -R ../../v0.9.12
|
||||||
|
|
||||||
# Install from binary
|
# Install from binary
|
||||||
nvm install 0.9.7
|
nvm install 0.9.7
|
||||||
nvm i 0.9.12
|
nvm i 0.9.12
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
[ -d ../../../v0.9.7 ]
|
[ -d ../../v0.9.7 ]
|
||||||
[ -d ../../../v0.9.12 ]
|
[ -d ../../v0.9.12 ]
|
||||||
|
|
||||||
# Use the first one
|
# Use the first one
|
||||||
nvm use 0.9.7
|
nvm use 0.9.7
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
. ../../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# 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
|
# Install from binary
|
||||||
cat "$NVM_TEST_VERSION" > .nvmrc
|
echo "$NVM_TEST_VERSION" > .nvmrc
|
||||||
|
|
||||||
nvm install
|
nvm install
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
[ -d ../../$NVM_TEST_VERSION ]
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
. ../../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# 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
|
# Install from binary
|
||||||
cat "$NVM_TEST_VERSION" > .nvmrc
|
echo "$NVM_TEST_VERSION" > .nvmrc
|
||||||
|
|
||||||
nvm install -s
|
nvm install -s
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
[ -d ../../$NVM_TEST_VERSION ]
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../nvm.sh
|
||||||
nvm uninstall v0.10.7
|
nvm uninstall v0.10.7
|
||||||
|
|
||||||
if [ -f ".nvmrc" ]; then
|
if [ -f ".nvmrc" ]; then
|
||||||
@@ -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'"
|
||||||
|
|
||||||
@@ -6,15 +6,15 @@ die () { echo "$@" ; exit 1; }
|
|||||||
|
|
||||||
nvm use 0.10.28
|
nvm use 0.10.28
|
||||||
|
|
||||||
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp npm recursive-blame uglify-js yo"
|
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp recursive-blame uglify-js yo"
|
||||||
|
|
||||||
npm install -g --quiet $EXPECTED_PACKAGES
|
echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet
|
||||||
|
|
||||||
nvm use 0.10.29
|
nvm use 0.10.29
|
||||||
ORIGINAL_PACKAGES=$(npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | grep -o -e '/[^/]*$' | cut -c 2- | sort | uniq | xargs)
|
ORIGINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
|
||||||
|
|
||||||
nvm copy-packages 0.10.28
|
nvm copy-packages 0.10.28
|
||||||
FINAL_PACKAGES=$(npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | grep -o -e '/[^/]*$' | cut -c 2- | sort | uniq | xargs)
|
FINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
|
||||||
|
|
||||||
[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)"
|
[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)"
|
||||||
[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)"
|
[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)"
|
||||||
|
|||||||
Reference in New Issue
Block a user