Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.js support #616

Merged
merged 24 commits into from
Jan 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3fa11c3
Add io.js support to `nvm_version_dir`
ljharb Jan 12, 2015
8be97c8
Add `nvm_iojs_prefix`
ljharb Jan 13, 2015
c12104c
Add `nvm_strip_iojs_prefix`
ljharb Jan 13, 2015
f661617
Make `nvm_ls foo` work with `iojs`-prefixed version strings.
ljharb Jan 13, 2015
5c336a7
Make `nvm_print_versions` support iojs via `nvm_version_path`.
ljharb Jan 13, 2015
b798384
Add `nvm_add_iojs_prefix`
ljharb Jan 13, 2015
d28703f
Update `nvm_ensure_version_prefix` to support `iojs`-prefixed version…
ljharb Jan 13, 2015
5143de9
Make `nvm_ls_current` work with `iojs`-prefixed versions.
ljharb Jan 13, 2015
d70f035
Add `nvm_ls_remote_iojs` and `nvm ls-remote` support for iojs.
ljharb Jan 13, 2015
58ab2c3
Add iojs support to `nvm_remote_version`
ljharb Jan 13, 2015
c46748a
Add `nvm_node_prefix`
ljharb Jan 13, 2015
98e0655
Add `nvm_is_iojs_version`
ljharb Jan 13, 2015
b0d6c05
Make `nvm ls-remote iojs [foo]` only show iojs versions, and `nvm ls-…
ljharb Jan 13, 2015
d9340b6
io.js does not have a SunOS binary.
ljharb Jan 14, 2015
41c3798
Make sure `nvm run` works with iojs prefixes.
ljharb Jan 15, 2015
dd3a376
Add `io.js` support to `nvm uninstall`
ljharb Jan 16, 2015
952096d
Add iojs support to "install"
ljharb Jan 14, 2015
ed22d3d
Add support for `nvm install node` and `nvm install iojs`
ljharb Jan 16, 2015
3cf68dc
Add `nvm_has_system_iojs`
ljharb Jan 19, 2015
39a75e6
Add support for `nvm use node`, `nvm use iojs`, `nvm ls node`, and `n…
ljharb Jan 19, 2015
dbeeb68
Fix `nvm_strip_path` for >= v0.12.0 node, and all io.js versions.
ljharb Jan 19, 2015
247bd31
Clean up `nvm uninstall node` and `nvm uninstall iojs` behavior.
ljharb Jan 19, 2015
f1f11e3
Ensure `nvm_version node` and `nvm_version node-` report the latest s…
ljharb Jan 19, 2015
ea12784
Clean up `nvm ls-remote` behavior when one of node/iojs reports N/A.
ljharb Jan 19, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
432 changes: 366 additions & 66 deletions nvm.sh

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

. ../../../nvm.sh

nvm ls node
nvm ls node_
[ "$?" = "3" ]

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ mkdir ../../../v0.0.9
mkdir ../../../v0.3.1
mkdir ../../../v0.3.3
mkdir ../../../v0.3.9
mkdir -p ../../../versions/node/v0.12.87
mkdir -p ../../../versions/node/v0.12.9
mkdir -p ../../../versions/io.js/v0.1.2
mkdir -p ../../../versions/io.js/v0.10.2

# The result should contain the version numbers.
nvm ls | grep v0.0.1 &&
nvm ls | grep v0.0.3 &&
nvm ls | grep v0.0.9 &&
nvm ls | grep v0.3.1 &&
nvm ls | grep v0.3.3 &&
nvm ls | grep v0.3.9
nvm ls | grep v0.0.1 >/dev/null &&
nvm ls | grep v0.0.3 >/dev/null &&
nvm ls | grep v0.0.9 >/dev/null &&
nvm ls | grep v0.3.1 >/dev/null &&
nvm ls | grep v0.3.3 >/dev/null &&
nvm ls | grep v0.3.9 >/dev/null &&
nvm ls | grep v0.12.87 >/dev/null &&
nvm ls | grep iojs-v0.1.2 >/dev/null
9 changes: 9 additions & 0 deletions test/fast/Unit tests/nvm_add_iojs_prefix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

[ "_$(nvm_add_iojs_prefix 1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix 1" did not return "iojs-v1"'
[ "_$(nvm_add_iojs_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix iojs-1" did not return "iojs-v1"'
[ "_$(nvm_add_iojs_prefix iojs-1.2.3)" = "_iojs-v1.2.3" ] || die '"nvm_add_iojs_prefix iojs-1.2.3" did not return "iojs-v1.2.3"'
3 changes: 3 additions & 0 deletions test/fast/Unit tests/nvm_ensure_version_prefix
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ die () { echo $@ ; exit 1; }
[ "_$(nvm_ensure_version_prefix 1)" = "_v1" ] || die '"nvm_ensure_version_prefix 1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix v1)" = "_v1" ] || die '"nvm_ensure_version_prefix v1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix foo)" = "_foo" ] || die '"nvm_ensure_version_prefix foo" did not return "foo"'

[ "_$(nvm_ensure_version_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-1" did not return "iojs-v1"'
[ "_$(nvm_ensure_version_prefix iojs-v1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-v1" did not return "iojs-v1"'
31 changes: 31 additions & 0 deletions test/fast/Unit tests/nvm_has_system_iojs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

cleanup () {
rm ../../../versions/io.js/v0.1.2/node
rm ../../../versions/io.js/v0.1.2/iojs
rmdir ../../../versions/io.js/v0.1.2
}
die () { echo $@ ; exit 1; }

. ../../../nvm.sh

mkdir ../../../versions/io.js/v0.1.2
touch ../../../versions/io.js/v0.1.2/node
touch ../../../versions/io.js/v0.1.2/iojs

nvm use iojs-v0.1.2

if command -v iojs; then
nvm_has_system_iojs
else
! nvm_has_system_iojs
fi

nvm deactivate /dev/null 2>&1

if command -v iojs; then
nvm_has_system_iojs
else
! nvm_has_system_iojs
fi

7 changes: 7 additions & 0 deletions test/fast/Unit tests/nvm_iojs_prefix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

[ "$(nvm_iojs_prefix)" = "iojs" ] || die '"nvm_iojs_prefix" did not return the string "iojs". why did this fail?!'
10 changes: 10 additions & 0 deletions test/fast/Unit tests/nvm_is_iojs_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

nvm_is_iojs_version 'iojs-' || die '"nvm_is_iojs_version iojs- was not true'
nvm_is_iojs_version 'iojs-foo' || die '"nvm_is_iojs_version iojs- was not true'
! nvm_is_iojs_version 'iojs' || die '"nvm_is_iojs_version iojs was not false'
! nvm_is_iojs_version 'v1.0.0' || die '"nvm_is_iojs_version v1.0.0" was not false'
34 changes: 34 additions & 0 deletions test/fast/Unit tests/nvm_ls_remote_iojs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

die () { echo $@ ; cleanup ; exit 1; }

cleanup() {
unset -f nvm_download
}

. ../../../nvm.sh

# sample output at the time the test was written
nvm_download() {
echo 'version date files npm v8 uv zlib openssl modules'
echo 'v1.0.1 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-tar,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi'
echo 'v1.0.0 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-tar,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi'
}

OUTPUT="$(nvm_ls_remote_iojs foo)"
EXIT_CODE="$(nvm_ls_remote_iojs foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"

OUTPUT="$(nvm_ls_remote_iojs)"
EXPECTED_OUTPUT="$(nvm_download | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | sed -e 's/^/iojs-/')"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote_iojs did not output expected sorted versions; got $(echo "$OUTPUT") expected $(echo "$EXPECTED_OUTPUT")"

OUTPUT="$(nvm_ls_remote_iojs 1.0)"
EXPECTED_OUTPUT="iojs-v1.0.0
iojs-v1.0.1"

[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote_iojs 1.0 did not output 1.0.x versions; got $OUTPUT"

cleanup

7 changes: 7 additions & 0 deletions test/fast/Unit tests/nvm_node_prefix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

[ "$(nvm_node_prefix)" = "node" ] || die '"nvm_node_prefix" did not return the string "node". why did this fail?!'
25 changes: 21 additions & 4 deletions test/fast/Unit tests/nvm_remote_version
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,50 @@
die () { echo $@ ; cleanup ; exit 1; }

cleanup() {
unset -f nvm_ls_remote
unset -f nvm_ls_remote nvm_ls_remote_iojs
}

. ../../../nvm.sh

nvm_ls_remote() {
echo "N/A"
}

OUTPUT="$(nvm_remote_version foo)"
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"

nvm_ls_remote_iojs() {
echo "N/A"
}
OUTPUT="$(nvm_remote_version iojs-foo)"
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"


nvm_ls_remote() {
echo "test output"
echo "more test output"
echo "pattern received: _$1_"
}

OUTPUT="$(nvm_remote_version foo)"
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"

[ "_$OUTPUT" = "_pattern received: _foo_" ] \
|| 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"

cleanup

10 changes: 10 additions & 0 deletions test/fast/Unit tests/nvm_strip_iojs_prefix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

[ "_$(nvm_strip_iojs_prefix iojs)" = "_" ] || die '"nvm_strip_iojs_prefix iojs" did not return an empty string'
[ "_$(nvm_strip_iojs_prefix iojs-)" = "_" ] || die '"nvm_strip_iojs_prefix iojs-" did not return an empty string'
[ "_$(nvm_strip_iojs_prefix iojs-foo)" = "_foo" ] || die '"nvm_strip_iojs_prefix iojs-foo" did not return "foo"'
[ "_$(nvm_strip_iojs_prefix iojsfoo)" = "_iojsfoo" ] || die '"nvm_strip_iojs_prefix iojsfoo" did not return "iojsfoo"'
2 changes: 1 addition & 1 deletion test/fast/Unit tests/nvm_strip_path
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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
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:$NVM_DIR/versions/node/v0.12.0/bin:$NVM_DIR/versions/io.js/v1.0.0/bin

STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"`

Expand Down
48 changes: 48 additions & 0 deletions test/fast/Unit tests/nvm_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh

die () { echo $@ ; cleanup ; exit 1; }
cleanup () {
unset -f nvm_ls_current nvm_ls
}

. ../../../nvm.sh

nvm_ls_current() {
echo "CURRENT!"
return 7
}

OUTPUT="$(nvm_version current)"
EXPECTED_OUTPUT="CURRENT!"
EXIT_CODE="$(nvm_version current 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version current" did not return nvm_ls_current output'
[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version current" did not return nvm_ls_current exit code'

OUTPUT="$(nvm_version)"
EXPECTED_OUTPUT="CURRENT!"
EXIT_CODE="$(nvm_version 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return nvm_ls_current output'
[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version" did not return nvm_ls_current exit code'

nvm_ls() {
echo "line 1"
echo "line 2"
echo "pattern: $1"
}
[ "_$(nvm_version foo)" = "_pattern: foo" ] || die '"nvm_version foo" did not pass the pattern to "nvm_ls", or return the last line'
[ "_$(nvm_version node)" = "_pattern: stable" ] || die '"nvm_version node" did not pass "stable" to "nvm_ls"'
[ "_$(nvm_version node-)" = "_pattern: stable" ] || die '"nvm_version node-" did not pass "stable" to "nvm_ls"'

nvm_ls() { echo "N/A"; }
OUTPUT="$(nvm_version foo)"
EXPECTED_OUTPUT="N/A"
EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns N/A'
[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3'

nvm_ls() { echo; }
OUTPUT="$(nvm_version foo)"
EXPECTED_OUTPUT="N/A"
EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns nothing'
[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3'
1 change: 1 addition & 0 deletions test/fast/Unit tests/nvm_version_dir
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ die () { echo $@ ; exit 1; }
. ../../../nvm.sh

[ "$(nvm_version_dir)" = "$NVM_DIR/versions/node" ] || die '"nvm_version_dir" did not return new dir path'
[ "$(nvm_version_dir iojs)" = "$NVM_DIR/versions/io.js" ] || die '"nvm_version_dir iojs" did not return iojs 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'
Expand Down
1 change: 1 addition & 0 deletions test/fast/Unit tests/nvm_version_path
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ die () { echo $@ ; exit 1; }
[ "$(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/node/v0.12.0" ] || die 'new version has the wrong path'
[ "$(nvm_version_path iojs-v0.12.0)" = "$NVM_DIR/versions/io.js/v0.12.0" ] || die 'iojs version has the wrong path'

26 changes: 26 additions & 0 deletions test/installation/io.js/install already installed uses it
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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 ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1

# Install from binary
nvm install iojs-v1.0.0
nvm install iojs-v1.0.1

nvm use iojs-v1.0.0

node --version | grep v1.0.0 || die "precondition failed: iojs node doesn't start at v1.0.0"
iojs --version | grep v1.0.0 || die "precondition failed: iojs binary doesn't start at v1.0.0"

nvm install iojs-v1.0.1

node --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (node binary)"
iojs --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (iojs binary)"

19 changes: 19 additions & 0 deletions test/installation/io.js/install from binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

NVM_TEST_VERSION="v1.0.0"
NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"

# Remove the stuff we're clobbering.
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION

# Install from binary
nvm install $NVM_PREFIXED_TEST_VERSION || die "install $NVM_PREFIXED_TEST_VERSION failed"

# Check
[ -d ../../../versions/io.js/$NVM_TEST_VERSION ]
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

# Remove the stuff we're clobbering.
[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0
[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1

# Install from binary
nvm install iojs-v1.0.0 || die "'nvm install iojs-v1.0.0' failed"
nvm i iojs-v1.0.1 || die "'nvm i iojs-v1.0.1' failed"

# Check
[ -d ../../../versions/io.js/v1.0.0 ] || die "iojs v1.0.0 didn't exist"
[ -d ../../../versions/io.js/v1.0.1 ] || die "iojs v1.0.1 didn't exist"

# Use the first one
nvm use iojs-1.0.0 || die "'nvm use iojs-1.0.0' failed"

# Use the latest one
nvm use iojs-1 || die "'nvm use iojs-1' failed"
[ "_$(node --version)" = "_v1.0.1" ] || die "'node --version' was not v1.0.1, got: $(node --version)"
[ "_$(iojs --version)" = "_v1.0.1" ] || die "'iojs --version' was not v1.0.1, got: $(iojs --version)"

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

NVM_TEST_VERSION=v1.0.0
NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION"
VERSION_PATH="../../../versions/io.js/$NVM_TEST_VERSION"

# Remove the stuff we're clobbering.
[ -e $VERSION_PATH ] && rm -R $VERSION_PATH

# Install from binary
echo "$NVM_PREFIXED_TEST_VERSION" > .nvmrc

nvm install || die "'nvm install' failed"

# Check
[ -d $VERSION_PATH ] || die "./$VERSION_PATH did not exist"
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION \
|| "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"


Loading