Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d96e4a6bf | ||
|
|
a00a3a7429 | ||
|
|
1c3585e5a2 | ||
|
|
214ce8853b | ||
|
|
d24dc662dc | ||
|
|
e8056ac460 | ||
|
|
429656bc41 | ||
|
|
b61445cbf4 | ||
|
|
603253b0cb | ||
|
|
5ee955bb62 | ||
|
|
83a0efb085 | ||
|
|
9306a9b3f0 | ||
|
|
59939d09e8 | ||
|
|
814319d7c0 | ||
|
|
4b3d6f1760 | ||
|
|
56c40cfa3c |
@@ -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.15.0/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.15.0/install.sh | bash
|
||||||
|
|
||||||
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
|
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
|
||||||
|
|
||||||
@@ -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.15.0/install.sh
|
||||||
[3]: https://travis-ci.org/creationix/nvm
|
[3]: https://travis-ci.org/creationix/nvm
|
||||||
[Urchin]: https://github.com/scraperwiki/urchin
|
[Urchin]: https://github.com/scraperwiki/urchin
|
||||||
|
|
||||||
|
|||||||
@@ -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.15.0 && 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.15.0/nvm.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Downloading to $NVM_DIR
|
# Downloading to $NVM_DIR
|
||||||
|
|||||||
20
nvm.sh
20
nvm.sh
@@ -284,12 +284,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
|
||||||
@@ -647,7 +647,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 +785,13 @@ nvm() {
|
|||||||
nvm help
|
nvm help
|
||||||
return 127
|
return 127
|
||||||
fi
|
fi
|
||||||
VERSION=$(nvm_version "$2")
|
VERSION="$(nvm_version "$2")"
|
||||||
local ROOT
|
|
||||||
ROOT=$(nvm use $VERSION && npm -g root)
|
|
||||||
|
|
||||||
# declare local INSTALLS first, otherwise it doesn't work in zsh
|
# declare local INSTALLS first, otherwise it doesn't work in zsh
|
||||||
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)
|
INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs)
|
||||||
|
|
||||||
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 +801,7 @@ nvm() {
|
|||||||
nvm_version $2
|
nvm_version $2
|
||||||
;;
|
;;
|
||||||
"--version" )
|
"--version" )
|
||||||
echo "0.14.0"
|
echo "0.15.0"
|
||||||
;;
|
;;
|
||||||
"unload" )
|
"unload" )
|
||||||
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater > /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.15.0",
|
||||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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