Compare commits

...

11 Commits

Author SHA1 Message Date
Jordan Harband
0f1f3ed29c v0.23.3 2015-02-02 20:26:00 -08:00
Jordan Harband
2116d2ff91 Filter out the io.js version dir from nvm_ls output.
Fixes #642.
2015-02-02 17:41:04 -08:00
Jordan Harband
0b4c1e14cf Ensure that nvm run 0.12 --version errors out sensibly when 0.12 isn't installed. 2015-02-01 13:02:46 -08:00
Jordan Harband
e1b7496cf0 Add nvm_is_valid_version 2015-02-01 13:01:40 -08:00
Jordan Harband
8a87133f71 When there's no nvm run output, don't echo an empty line. 2015-02-01 12:45:51 -08:00
Jordan Harband
0792945824 Bypass sha1sum/sha1 aliases. Fixes #640. 2015-01-30 23:46:42 -08:00
Jordan Harband
a6819b3018 Fix nvm ls v1.0.3 so that it locates iojs-v1.0.3.
Also fix `nvm uninstall v1.0.3` so it won't uninstall it if it's the current version.

node versions will still take priority if there's ever a version overlap.
2015-01-25 12:31:19 -08:00
Jordan Harband
3d3d9d3a8d Merge pull request #633 from gsklee/patch-1
Update README.markdown
2015-01-25 10:13:53 -08:00
G. Kay Lee
3e74bac964 Update README.markdown
Add link to io.js repo as suggested in #618
2015-01-25 15:29:36 +08:00
Jordan Harband
1eaf6b53e4 v0.23.2 2015-01-23 13:53:03 -08:00
Jordan Harband
24c60e4e51 Fix a bug in nvm_remote_version that was breaking nvm install stable/nvm install unstable.
Fixes #630.
2015-01-23 12:09:13 -08:00
9 changed files with 103 additions and 26 deletions

View File

@@ -12,11 +12,11 @@ Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/n
To install you could use the [install script][2] using cURL:
curl https://raw.githubusercontent.com/creationix/nvm/v0.23.1/install.sh | bash
curl https://raw.githubusercontent.com/creationix/nvm/v0.23.3/install.sh | bash
or Wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.23.1/install.sh | bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.23.3/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>
@@ -72,7 +72,7 @@ In place of a version pointer like "0.10", you can use the special default alias
nvm use stable
nvm run unstable --version
If you want to install `io.js`:
If you want to install [io.js](https://github.com/iojs/io.js/):
nvm install iojs
@@ -202,7 +202,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.23.1/install.sh
[2]: https://github.com/creationix/nvm/blob/v0.23.3/install.sh
[3]: https://travis-ci.org/creationix/nvm
[Urchin]: https://github.com/scraperwiki/urchin

View File

@@ -11,7 +11,7 @@ if [ -z "$NVM_DIR" ]; then
fi
nvm_latest_version() {
echo "v0.23.1"
echo "v0.23.3"
}
#

47
nvm.sh
View File

@@ -218,7 +218,7 @@ nvm_remote_version() {
PATTERN="$1"
local VERSION
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
VERSIONS="$(nvm_ls_remote "$PATTERN")"
VERSION="$(nvm_ls_remote "$PATTERN")"
else
case "_$PATTERN" in
"_$(nvm_node_prefix)")
@@ -263,6 +263,22 @@ $(nvm_ls_remote_iojs "$PATTERN")" | command grep -v "N/A" | command sed '/^$/d')
fi
}
nvm_is_valid_version() {
if nvm_validate_implicit_alias "$1" 2> /dev/null; then
return 0
fi
case "$1" in
"$(nvm_iojs_prefix)" | "$(nvm_node_prefix)")
return 0
;;
*)
local VERSION
VERSION="$(nvm_strip_iojs_prefix "$1")"
nvm_version_greater "$VERSION"
;;
esac
}
nvm_normalize_version() {
echo "$1" | command sed -e 's/^v//' | command awk -F. '{ printf("%d%06d%06d\n", $1,$2,$3); }'
}
@@ -469,6 +485,8 @@ nvm_ls() {
if [ "_$(echo "$PATTERN" | cut -c1-1)" = "_v" ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
VERSIONS="$PATTERN"
elif [ -d "$(nvm_version_path "$(nvm_add_iojs_prefix "$PATTERN")")" ]; then
VERSIONS="$(nvm_add_iojs_prefix "$PATTERN")"
fi
else
case "$PATTERN" in
@@ -523,6 +541,7 @@ nvm_ls() {
fi
VERSIONS="$(command find $NVM_DIRS_TO_SEARCH -maxdepth 1 -type d -name "$PATTERN*" \
| command sed "s#$(nvm_version_dir iojs)/#"$(nvm_iojs_prefix)"-#" \
| command grep -v "$(nvm_version_dir iojs)" \
| command sed "s#^$NVM_DIR/##" \
| command grep -v -e '^versions$' \
| command sed 's#^versions/##' \
@@ -602,9 +621,9 @@ nvm_ls_remote_iojs() {
nvm_checksum() {
if nvm_has "sha1sum"; then
checksum="$(sha1sum "$1" | command awk '{print $1}')"
checksum="$(command sha1sum "$1" | command awk '{print $1}')"
elif nvm_has "sha1"; then
checksum="$(sha1 -q "$1")"
checksum="$(command sha1 -q "$1")"
else
checksum="$(shasum "$1" | command awk '{print $1}')"
fi
@@ -1081,8 +1100,8 @@ nvm() {
VERSION="$(nvm_version "$PATTERN")"
;;
esac
if [ "_$PATTERN" = "_$(nvm_ls_current)" ]; then
if nvm_is_iojs_version "$PATTERN"; then
if [ "_$VERSION" = "_$(nvm_ls_current)" ]; then
if nvm_is_iojs_version "$VERSION"; then
echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2
else
echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2
@@ -1253,7 +1272,7 @@ nvm() {
provided_version=$1
if [ -n "$provided_version" ]; then
VERSION="$(nvm_version "$provided_version")"
if [ "_$VERSION" = "_N/A" ]; then
if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then
provided_version=''
if [ $has_checked_nvmrc -ne 1 ]; then
nvm_rc_version && has_checked_nvmrc=1
@@ -1272,17 +1291,23 @@ nvm() {
local ARGS
ARGS="$@"
local OUTPUT
local EXIT_CODE
if [ "$NVM_IOJS" = true ]; then
if [ "_$VERSION" = "_N/A" ]; then
echo "$(nvm_ensure_version_prefix "$provided_version") is not installed yet" >&2
EXIT_CODE=1
elif [ "$NVM_IOJS" = true ]; then
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")"
OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs "$ARGS")"
EXIT_CODE="$?"
else
echo "Running node $VERSION"
OUTPUT="$(nvm use "$VERSION" >/dev/null && node "$ARGS")"
EXIT_CODE="$?"
fi
if [ -n "$OUTPUT" ]; then
echo "$OUTPUT"
fi
local EXIT_CODE
EXIT_CODE="$?"
echo "$OUTPUT"
return $EXIT_CODE
;;
"exec" )
@@ -1502,7 +1527,7 @@ $NVM_LS_REMOTE_IOJS_OUTPUT" | command grep -v "N/A" | sed '/^$/d')"
nvm_version $2
;;
"--version" )
echo "0.23.1"
echo "0.23.3"
;;
"unload" )
unset -f nvm nvm_print_versions nvm_checksum \

View File

@@ -1,6 +1,6 @@
{
"name": "nvm",
"version": "0.23.1",
"version": "0.23.3",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": {
"test": "test"

View File

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

View File

@@ -0,0 +1,13 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm_is_valid_version 0.1.2 || die "nvm_is_valid_version 0.1.2 did not return 0"
nvm_is_valid_version foo && die "nvm_is_valid_version foo did not return 1"
nvm_is_valid_version iojs-1 || die "nvm_is_valid_version iojs-1 did not return 0"
nvm_is_valid_version iojs || die "nvm_is_valid_version iojs did not return 0"
nvm_is_valid_version node || die "nvm_is_valid_version node did not return 0"
nvm_is_valid_version stable || die "nvm_is_valid_version stable did not return 0"
nvm_is_valid_version unstable || die "nvm_is_valid_version unstable did not return 0"

View File

@@ -26,9 +26,18 @@ EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
nvm_ls_remote() {
echo "test output"
echo "more test output"
echo "pattern received: _$1_"
if ! nvm_is_iojs_version "$1"; then
echo "test output"
echo "more test output"
echo "pattern received: _$1_"
fi
}
nvm_ls_remote_iojs() {
if nvm_is_iojs_version "$1"; then
echo "test iojs output"
echo "more iojs test output"
echo "iojs pattern received: _$1_"
fi
}
OUTPUT="$(nvm_remote_version foo)"
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
@@ -36,17 +45,17 @@ EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|| die "nvm_remote_version foo did not return last line only of nvm_ls_remote foo; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version foo did not exit with 0, got $EXIT_CODE"
nvm_ls_remote_iojs() {
echo "test iojs output"
echo "more iojs test output"
echo "iojs pattern received: _$1_"
}
OUTPUT="$(nvm_remote_version iojs-foo)"
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_iojs pattern received: _iojs-foo_" ] \
|| die "nvm_remote_version iojs-foo did not return last line only of nvm_ls_remote_iojs foo; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE"
OUTPUT="$(nvm_remote_version stable)"
EXIT_CODE="$(nvm_remote_version stable >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_$(nvm_ls_remote stable)" ] \
|| die "nvm_remote_version stable did not return contents of nvm_ls_remote stable; got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version stable did not exit with 0, got $EXIT_CODE"
cleanup

View File

@@ -0,0 +1,9 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "$(nvm run 0.2 --version 2>&1)" = "v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly"
[ "$(nvm run iojs-0.2 --version 2>&1)" = "iojs-v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"

View File

@@ -0,0 +1,14 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
nvm use 'v1.0.0' || die 'nvm use v1.0.0 failed'
OUTPUT="$(nvm current)"
EXPECTED_OUTPUT="$(nvm_version v1.0.0)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|| die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"