Compare commits
351 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
448bd38a55 | ||
|
|
0ad5a450fe | ||
|
|
d5e21be164 | ||
|
|
797c5ab70b | ||
|
|
0e209ce890 | ||
|
|
9a57a891b9 | ||
|
|
3d5ded1815 | ||
|
|
7807a9f09e | ||
|
|
835c006b5e | ||
|
|
34e51f9f02 | ||
|
|
4b5885d69d | ||
|
|
bf794ff8da | ||
|
|
0bd7372c64 | ||
|
|
0a142b7e7a | ||
|
|
3fc82d6b2f | ||
|
|
c6489440dc | ||
|
|
67e8939311 | ||
|
|
a26007ec0d | ||
|
|
3f5ce8b93a | ||
|
|
8328741792 | ||
|
|
8e45afb9f1 | ||
|
|
fd2fb24b03 | ||
|
|
4708cc73ef | ||
|
|
c91e8d0ba2 | ||
|
|
f8b143c594 | ||
|
|
9a4e9060d8 | ||
|
|
3df0caefa5 | ||
|
|
274369dc40 | ||
|
|
bef3a5ce3a | ||
|
|
0cb8c9ac2f | ||
|
|
25c61594fe | ||
|
|
0a739e3fa9 | ||
|
|
c0a20f2fa3 | ||
|
|
2d78d69d4c | ||
|
|
9e17b5059c | ||
|
|
0ac2c787be | ||
|
|
99ca0de18f | ||
|
|
f196ace5dd | ||
|
|
d1a90ca15c | ||
|
|
b3178ca925 | ||
|
|
b9df3fccb4 | ||
|
|
f408d68afc | ||
|
|
fc3a30dd0e | ||
|
|
74b36b09ff | ||
|
|
080f2149ac | ||
|
|
3bd148056e | ||
|
|
5edf013127 | ||
|
|
ae908cbff6 | ||
|
|
7805492bda | ||
|
|
a1c0c34088 | ||
|
|
234b925c7a | ||
|
|
8964cb46d3 | ||
|
|
383f39ab61 | ||
|
|
052743816f | ||
|
|
7bbcd3a977 | ||
|
|
e728577627 | ||
|
|
c33074cb54 | ||
|
|
689c52c90d | ||
|
|
5904d41b25 | ||
|
|
0c33fd2598 | ||
|
|
c9a53fe0c7 | ||
|
|
8b25457b74 | ||
|
|
ee520abf78 | ||
|
|
b63042bd9f | ||
|
|
382c3aa85e | ||
|
|
afba4e08fd | ||
|
|
ce82109229 | ||
|
|
516e553093 | ||
|
|
e28a257f23 | ||
|
|
2d8adac785 | ||
|
|
bf4bf008ac | ||
|
|
5f5eb47f14 | ||
|
|
d09b84de3c | ||
|
|
4b6075e29b | ||
|
|
781f72c9c8 | ||
|
|
6ec62fcc79 | ||
|
|
fc17aaafb1 | ||
|
|
ac912afc4c | ||
|
|
b9f15b0ab0 | ||
|
|
d30c0fe146 | ||
|
|
21534ec0c9 | ||
|
|
3cdec8e875 | ||
|
|
cec1c38a84 | ||
|
|
ad0a5cd8c7 | ||
|
|
1c9a5ba2d8 | ||
|
|
fd1f2cdf66 | ||
|
|
2d529cc8b7 | ||
|
|
9b91734f0b | ||
|
|
0f5997f754 | ||
|
|
7a339bdd3c | ||
|
|
08aa09e664 | ||
|
|
8284cd0f81 | ||
|
|
e421a0dc5f | ||
|
|
601490ac1d | ||
|
|
4748b3a236 | ||
|
|
2a61569881 | ||
|
|
a7b1f93592 | ||
|
|
ca89cceb99 | ||
|
|
7b6e06e556 | ||
|
|
370dfcab7c | ||
|
|
44d5776110 | ||
|
|
d49443e1fb | ||
|
|
e99645f402 | ||
|
|
8f76b35370 | ||
|
|
a2633e5980 | ||
|
|
6c89e96f67 | ||
|
|
1ee708b79b | ||
|
|
035334fd34 | ||
|
|
2edc86d574 | ||
|
|
9d23f609ad | ||
|
|
9d9cfdc2c8 | ||
|
|
1931f7f3f8 | ||
|
|
2f2c6f0727 | ||
|
|
0eef553a88 | ||
|
|
5135577a3c | ||
|
|
5bc6e289ce | ||
|
|
d0c6b87b2e | ||
|
|
66b214651f | ||
|
|
acfc459bc5 | ||
|
|
fc16d20766 | ||
|
|
f0471acbf5 | ||
|
|
fda05fb64b | ||
|
|
2737a95645 | ||
|
|
5706aef3d0 | ||
|
|
4cdf356cdc | ||
|
|
c918e570b6 | ||
|
|
5dc7af6285 | ||
|
|
f9565ff675 | ||
|
|
cea0e88489 | ||
|
|
5aad535d53 | ||
|
|
fcdd1ef431 | ||
|
|
cd4fc8fb2c | ||
|
|
050a2ee9d3 | ||
|
|
ff92ba7f43 | ||
|
|
804f2759f8 | ||
|
|
d5fe657382 | ||
|
|
3e4613fd66 | ||
|
|
9aec19a692 | ||
|
|
b707d8b072 | ||
|
|
be605cb12b | ||
|
|
3c66c20570 | ||
|
|
59bfdb9863 | ||
|
|
25bd2bb018 | ||
|
|
4a8a5a1180 | ||
|
|
145da7eef8 | ||
|
|
4cf56ae186 | ||
|
|
5ad00f13fa | ||
|
|
53f9841c6c | ||
|
|
444efdb08b | ||
|
|
6fde379707 | ||
|
|
ce69c8413e | ||
|
|
51f6109f8d | ||
|
|
4f081ce4be | ||
|
|
db0051753a | ||
|
|
cf1110ecea | ||
|
|
34b97bf76d | ||
|
|
b962a590a2 | ||
|
|
ddb25ed5a3 | ||
|
|
486d14f5f8 | ||
|
|
622fdd2cd0 | ||
|
|
eddbe15ee8 | ||
|
|
2e161fe414 | ||
|
|
a42b90d215 | ||
|
|
6bae6c07f2 | ||
|
|
7fd6d05426 | ||
|
|
5ef092b2c8 | ||
|
|
cb6456fd85 | ||
|
|
991fb85047 | ||
|
|
edf36a8ea7 | ||
|
|
35466187f2 | ||
|
|
c992b1766c | ||
|
|
4b2bc0be08 | ||
|
|
15b3e7b6a8 | ||
|
|
8d05ab63f1 | ||
|
|
da693eaea1 | ||
|
|
5363ff8916 | ||
|
|
e186fa27a7 | ||
|
|
f6e0104685 | ||
|
|
97d4e2f88f | ||
|
|
e0a22ccf4a | ||
|
|
d5d66c34d9 | ||
|
|
152904e3fb | ||
|
|
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 | ||
|
|
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 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -9,6 +9,7 @@ test/bak
|
|||||||
.urchin_stdout
|
.urchin_stdout
|
||||||
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
current
|
||||||
|
|||||||
35
.travis.yml
35
.travis.yml
@@ -1,14 +1,39 @@
|
|||||||
language: c # defaults to ruby
|
language: c # defaults to ruby
|
||||||
install:
|
install:
|
||||||
- sudo apt-get install ksh zsh -y
|
- sudo apt-get install zsh -y # ksh
|
||||||
before_script:
|
- (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s http://registry.npmjs.org/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*)
|
||||||
- curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin && chmod +x /tmp/urchin
|
- chmod +x /tmp/urchin/package/urchin
|
||||||
|
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
||||||
script:
|
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/package/urchin test-$SHELL
|
||||||
env:
|
env:
|
||||||
|
- SHELL=sh TEST_SUITE=install_script
|
||||||
|
- SHELL=dash TEST_SUITE=install_script
|
||||||
|
- SHELL=bash TEST_SUITE=install_script
|
||||||
|
- SHELL=zsh TEST_SUITE=install_script
|
||||||
|
# - SHELL=ksh TEST_SUITE=install_script
|
||||||
- SHELL=sh TEST_SUITE=fast
|
- SHELL=sh TEST_SUITE=fast
|
||||||
- SHELL=dash TEST_SUITE=fast
|
- SHELL=dash TEST_SUITE=fast
|
||||||
- SHELL=bash TEST_SUITE=fast
|
- SHELL=bash TEST_SUITE=fast
|
||||||
- SHELL=zsh TEST_SUITE=fast
|
- SHELL=zsh TEST_SUITE=fast
|
||||||
- SHELL=ksh TEST_SUITE=fast
|
# - SHELL=ksh TEST_SUITE=fast
|
||||||
- SHELL=sh TEST_SUITE=slow
|
- SHELL=sh TEST_SUITE=slow
|
||||||
|
- SHELL=dash TEST_SUITE=slow
|
||||||
|
- SHELL=bash TEST_SUITE=slow
|
||||||
|
- SHELL=zsh TEST_SUITE=slow
|
||||||
|
# - SHELL=ksh TEST_SUITE=slow
|
||||||
|
- SHELL=sh TEST_SUITE=sourcing
|
||||||
|
- SHELL=dash TEST_SUITE=sourcing
|
||||||
|
- SHELL=bash TEST_SUITE=sourcing
|
||||||
|
- SHELL=zsh TEST_SUITE=sourcing
|
||||||
|
# - SHELL=ksh TEST_SUITE=sourcing
|
||||||
|
- 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
|
||||||
|
|||||||
82
Makefile
82
Makefile
@@ -1,15 +1,77 @@
|
|||||||
URCHIN=`which urchin`
|
# Since we rely on paths relative to the makefile location, abort if make isn't being run from there.
|
||||||
SHELLS=sh bash dash ksh zsh
|
$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in))
|
||||||
TEST_SUITE=fast
|
# Note: With Travis CI:
|
||||||
|
# - the path to urchin is passed via the command line.
|
||||||
|
# - the other utilities are NOT needed, so we skip the test for their existence.
|
||||||
|
URCHIN := urchin
|
||||||
|
ifeq ($(findstring /,$(URCHIN)),) # urchin path was NOT passed in.
|
||||||
|
# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly.
|
||||||
|
# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment
|
||||||
|
# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests.
|
||||||
|
export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH")
|
||||||
|
# The list of all supporting utilities, installed with `npm install`.
|
||||||
|
UTILS := $(URCHIN) replace semver
|
||||||
|
# Make sure that all required utilities can be located.
|
||||||
|
UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS)))
|
||||||
|
endif
|
||||||
|
# The files that need updating when incrementing the version number.
|
||||||
|
VERSIONED_FILES := nvm.sh install.sh README.markdown package.json
|
||||||
|
# Define all shells to test with. Can be overridden with `make SHELLS=... <target>`.
|
||||||
|
SHELLS := sh bash dash zsh # ksh (#574)
|
||||||
|
# Generate 'test-<shell>' target names from specified shells.
|
||||||
|
# The embedded shell names are extracted on demand inside the recipes.
|
||||||
|
SHELL_TARGETS := $(addprefix test-,$(SHELLS))
|
||||||
|
# Define the default test suite(s). This can be overridden with `make TEST_SUITE=<...> <target>`.
|
||||||
|
# Test suites are the names of subfolders of './test'.
|
||||||
|
TEST_SUITE := $(shell find ./test/* -type d -prune -exec basename {} \;)
|
||||||
|
|
||||||
.PHONY: $(SHELLS) test
|
|
||||||
|
|
||||||
$(SHELLS):
|
# Default target (by virtue of being the first non '.'-prefixed in the file).
|
||||||
@printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@"
|
.PHONY: _no-target-specified
|
||||||
@$@ $(URCHIN) -f test/$(TEST_SUITE)
|
_no-target-specified:
|
||||||
|
$(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests)
|
||||||
|
|
||||||
test: $(SHELLS)
|
# Lists all targets defined in this makefile.
|
||||||
@$(URCHIN) -f test/slow
|
.PHONY: list
|
||||||
|
list:
|
||||||
|
@$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort
|
||||||
|
|
||||||
default: test
|
# Set of test-<shell> targets; each runs the specified test suites for a single shell.
|
||||||
|
# Note that preexisting NVM_* variables are unset to avoid interfering with tests, except when running the Travis tests (where NVM_DIR must be passed in and the env. is assumed to be pristine).
|
||||||
|
.PHONY: $(SHELL_TARGETS)
|
||||||
|
$(SHELL_TARGETS):
|
||||||
|
@shell='$@'; shell=$${shell##*-}; which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \
|
||||||
|
printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \
|
||||||
|
[ -z "$$TRAVIS_BUILD_DIR" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \
|
||||||
|
for suite in $(TEST_SUITE); do $(URCHIN) -f -s $$shell test/$$suite || exit; done
|
||||||
|
|
||||||
|
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
|
||||||
|
.PHONY: test
|
||||||
|
test: $(SHELL_TARGETS)
|
||||||
|
|
||||||
|
.PHONY: _ensure-tag
|
||||||
|
_ensure-tag:
|
||||||
|
ifndef TAG
|
||||||
|
$(error Please invoke with `make TAG=<new-version> release`, where <new-version> is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Ensures that the git workspace is clean.
|
||||||
|
.PHONY: _ensure-clean
|
||||||
|
_ensure-clean:
|
||||||
|
@[ -z "$$(git status --porcelain --untracked-files=no || echo err)" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; }
|
||||||
|
|
||||||
|
# Makes a release; invoke with `make TAG=<versionOrIncrementSpec> release`.
|
||||||
|
.PHONY: release
|
||||||
|
release: _ensure-tag _ensure-clean
|
||||||
|
@old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \
|
||||||
|
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
|
||||||
|
if printf "$$new_ver" | grep -q '^[0-9]'; then \
|
||||||
|
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
|
||||||
|
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
|
||||||
|
else \
|
||||||
|
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
|
||||||
|
fi; \
|
||||||
|
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
|
||||||
|
replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \
|
||||||
|
git commit -m "v$$new_ver" $(VERSIONED_FILES) && \
|
||||||
|
git tag -a -m "v$$new_ver" "v$$new_ver"
|
||||||
|
|||||||
@@ -2,31 +2,36 @@
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
||||||
|
|
||||||
|
Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Two alternatives exist, which are not supported nor developed by us:
|
||||||
|
- [nvmw](http://github.com/hakobera/nvmw)
|
||||||
|
- [nvm-windows](http://github.com/coreybutler/nvm-windows)
|
||||||
|
|
||||||
### Install script
|
### Install script
|
||||||
|
|
||||||
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.8.0/install.sh | sh
|
curl https://raw.githubusercontent.com/creationix/nvm/v0.22.2/install.sh | bash
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.8.0/install.sh | sh
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.22.2/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>
|
||||||
|
|
||||||
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
|
### Manual install
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
@@ -38,7 +43,7 @@ Often I also put in a line to use a specific version of node.
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
||||||
`nvm use`, `nvm install`, and `nvm run` will all respect an `.nvmrc` file.
|
`nvm use`, `nvm install`, `nvm exec`, `nvm run`, and `nvm which` will all respect an `.nvmrc` file when a version is not supplied.
|
||||||
|
|
||||||
To download, compile, and install the latest v0.10.x release of node, do this:
|
To download, compile, and install the latest v0.10.x release of node, do this:
|
||||||
|
|
||||||
@@ -52,6 +57,26 @@ Or you can just run it:
|
|||||||
|
|
||||||
nvm run 0.10 --version
|
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
|
||||||
|
|
||||||
|
You can also get the path to the executable to where it was installed:
|
||||||
|
|
||||||
|
nvm which 0.10
|
||||||
|
|
||||||
|
In place of a version pointer like "0.10", you can use the special default aliases "stable" and "unstable":
|
||||||
|
|
||||||
|
nvm install stable
|
||||||
|
nvm install unstable
|
||||||
|
nvm use stable
|
||||||
|
nvm run unstable --version
|
||||||
|
|
||||||
|
If you want to use the system-installed version of node, you can use the special default alias "system":
|
||||||
|
|
||||||
|
nvm use system
|
||||||
|
nvm run system --version
|
||||||
|
|
||||||
If you want to see what versions are installed:
|
If you want to see what versions are installed:
|
||||||
|
|
||||||
nvm ls
|
nvm ls
|
||||||
@@ -66,7 +91,7 @@ To restore your PATH, you can deactivate it.
|
|||||||
|
|
||||||
To set a default Node version to be used in any new shell, use the alias 'default':
|
To set a default Node version to be used in any new shell, use the alias 'default':
|
||||||
|
|
||||||
nvm alias default 0.10
|
nvm alias default stable
|
||||||
|
|
||||||
To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
|
To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
|
||||||
|
|
||||||
@@ -75,6 +100,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 not, by default, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to "true" to enable this behavior, which is sometimes useful for IDEs.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
nvm is released under the MIT license.
|
nvm is released under the MIT license.
|
||||||
@@ -123,8 +150,9 @@ Put the above sourcing line just below the sourcing line for NVM in your profile
|
|||||||
nvm
|
nvm
|
||||||
|
|
||||||
$ nvm [tab][tab]
|
$ nvm [tab][tab]
|
||||||
alias copy-packages help list run uninstall version
|
alias deactivate install ls run unload
|
||||||
clear-cache deactivate install ls unalias use
|
clear-cache exec list ls-remote unalias use
|
||||||
|
current help list-remote reinstall-packages uninstall version
|
||||||
|
|
||||||
nvm alias
|
nvm alias
|
||||||
|
|
||||||
@@ -163,7 +191,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.8.0/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.22.2/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
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ __nvm_commands ()
|
|||||||
current_word="${COMP_WORDS[COMP_CWORD]}"
|
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
|
||||||
COMMANDS='\
|
COMMANDS='\
|
||||||
help install uninstall use run\
|
help install uninstall use run exec \
|
||||||
ls ls-remote list list-remote deactivate\
|
alias unalias reinstall-packages \
|
||||||
alias unalias copy-packages clear-cache version'
|
current list ls list-remote ls-remote \
|
||||||
|
clear-cache deactivate unload \
|
||||||
|
version which'
|
||||||
|
|
||||||
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
||||||
|
|
||||||
@@ -79,8 +81,8 @@ __nvm ()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# complete is a bash builtin, but recent versions of ZSH come with a function
|
# complete is a bash builtin, but recent versions of ZSH come with a function
|
||||||
# called bashcompinit that will create a complete in ZSH. If the user is in
|
# called bashcompinit that will create a complete in ZSH. If the user is in
|
||||||
# ZSH, load and run bashcompinit before calling the complete function.
|
# ZSH, load and run bashcompinit before calling the complete function.
|
||||||
if [[ -n ${ZSH_VERSION-} ]]; then
|
if [[ -n ${ZSH_VERSION-} ]]; then
|
||||||
autoload -U +X bashcompinit && bashcompinit
|
autoload -U +X bashcompinit && bashcompinit
|
||||||
|
|||||||
222
install.sh
222
install.sh
@@ -2,51 +2,82 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
has() {
|
nvm_has() {
|
||||||
type "$1" > /dev/null 2>&1
|
type "$1" > /dev/null 2>&1
|
||||||
return $?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$NVM_DIR" ]; then
|
if [ -z "$NVM_DIR" ]; then
|
||||||
NVM_DIR="$HOME/.nvm"
|
NVM_DIR="$HOME/.nvm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! has "curl"; then
|
nvm_latest_version() {
|
||||||
if has "wget"; then
|
echo "v0.22.2"
|
||||||
# Emulate curl with wget
|
}
|
||||||
curl() {
|
|
||||||
ARGS="$* "
|
|
||||||
ARGS=${ARGS/-s /-q }
|
|
||||||
ARGS=${ARGS/-o /-O }
|
|
||||||
wget $ARGS
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
install_from_git() {
|
#
|
||||||
|
# Outputs the location to NVM depending on:
|
||||||
|
# * The availability of $NVM_SOURCE
|
||||||
|
# * The method used ("script" or "git" in the script, defaults to "git")
|
||||||
|
# NVM_SOURCE always takes precedence
|
||||||
|
#
|
||||||
|
nvm_source() {
|
||||||
|
local NVM_METHOD
|
||||||
|
NVM_METHOD="$1"
|
||||||
if [ -z "$NVM_SOURCE" ]; then
|
if [ -z "$NVM_SOURCE" ]; then
|
||||||
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
local NVM_SOURCE
|
||||||
|
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||||
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
|
||||||
|
elif [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||||
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
|
||||||
|
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||||
|
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||||
|
else
|
||||||
|
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo "$NVM_SOURCE"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
if [ -d "$NVM_DIR/.git" ]; then
|
nvm_download() {
|
||||||
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
if nvm_has "curl"; then
|
||||||
echo -e "\r=> \c"
|
curl $*
|
||||||
cd "$NVM_DIR" && git pull 2> /dev/null || {
|
elif nvm_has "wget"; then
|
||||||
echo >&2 "Failed to update nvm, run 'git pull' in $NVM_DIR yourself.."
|
# Emulate curl with wget
|
||||||
}
|
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
else
|
-e 's/-L //' \
|
||||||
# Cloning to $NVM_DIR
|
-e 's/-I /--server-response /' \
|
||||||
echo "=> Downloading nvm from git to '$NVM_DIR'"
|
-e 's/-s /-q /' \
|
||||||
echo -e "\r=> \c"
|
-e 's/-o /-O /' \
|
||||||
mkdir -p "$NVM_DIR"
|
-e 's/-C - /-c /')
|
||||||
git clone "$NVM_SOURCE" "$NVM_DIR"
|
wget $ARGS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_as_script() {
|
install_nvm_from_git() {
|
||||||
if [ -z "$NVM_SOURCE" ]; then
|
if [ -d "$NVM_DIR/.git" ]; then
|
||||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh"
|
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
||||||
|
printf "\r=> "
|
||||||
|
cd "$NVM_DIR" && (command 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'"
|
||||||
|
printf "\r=> "
|
||||||
|
mkdir -p "$NVM_DIR"
|
||||||
|
command git clone "$(nvm_source git)" "$NVM_DIR"
|
||||||
fi
|
fi
|
||||||
|
cd "$NVM_DIR" && command git checkout --quiet $(nvm_latest_version) && command git branch --quiet -D master >/dev/null 2>&1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
install_nvm_as_script() {
|
||||||
|
local NVM_SOURCE
|
||||||
|
NVM_SOURCE=$(nvm_source script)
|
||||||
|
local NVM_EXEC_SOURCE
|
||||||
|
NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
|
||||||
|
|
||||||
# Downloading to $NVM_DIR
|
# Downloading to $NVM_DIR
|
||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
@@ -55,74 +86,99 @@ install_as_script() {
|
|||||||
else
|
else
|
||||||
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||||
fi
|
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'.."
|
echo >&2 "Failed to download '$NVM_SOURCE'"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
nvm_download -s "$NVM_EXEC_SOURCE" -o "$NVM_DIR/nvm-exec" || {
|
||||||
|
echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
chmod a+x "$NVM_DIR/nvm-exec" || {
|
||||||
|
echo >&2 "Failed to mark '$NVM_DIR/nvm-exec' as executable"
|
||||||
|
return 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$METHOD" ]; then
|
#
|
||||||
# Autodetect install method
|
# Detect profile file if not specified as environment variable
|
||||||
if has "git"; then
|
# (eg: PROFILE=~/.myprofile)
|
||||||
install_from_git
|
# The echo'ed path is guaranteed to be an existing file
|
||||||
elif has "curl"; then
|
# Otherwise, an empty string is returned
|
||||||
install_as_script
|
#
|
||||||
else
|
nvm_detect_profile() {
|
||||||
echo >&2 "You need git, curl or wget to install nvm"
|
if [ -f "$PROFILE" ]; then
|
||||||
exit 1
|
echo "$PROFILE"
|
||||||
|
elif [ -f "$HOME/.bashrc" ]; then
|
||||||
|
echo "$HOME/.bashrc"
|
||||||
|
elif [ -f "$HOME/.bash_profile" ]; then
|
||||||
|
echo "$HOME/.bash_profile"
|
||||||
|
elif [ -f "$HOME/.zshrc" ]; then
|
||||||
|
echo "$HOME/.zshrc"
|
||||||
|
elif [ -f "$HOME/.profile" ]; then
|
||||||
|
echo "$HOME/.profile"
|
||||||
fi
|
fi
|
||||||
else
|
}
|
||||||
if [ "$METHOD" = "git" ]; then
|
|
||||||
if ! has "git"; then
|
nvm_do_install() {
|
||||||
|
if [ -z "$METHOD" ]; then
|
||||||
|
# Autodetect install method
|
||||||
|
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"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
elif [ "~$METHOD" = "~git" ]; then
|
||||||
|
if ! nvm_has "git"; then
|
||||||
echo >&2 "You need git to install nvm"
|
echo >&2 "You need git to install nvm"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
install_from_git
|
install_nvm_from_git
|
||||||
fi
|
elif [ "~$METHOD" = "~script" ]; then
|
||||||
if [ "$METHOD" = "script" ]; then
|
if ! nvm_has "nvm_download"; then
|
||||||
if ! has "curl"; then
|
|
||||||
echo >&2 "You need curl or wget to install nvm"
|
echo >&2 "You need curl or wget to install nvm"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
install_as_script
|
install_nvm_as_script
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile).
|
|
||||||
if [ -z "$PROFILE" ]; then
|
|
||||||
if [ -f "$HOME/.bash_profile" ]; then
|
|
||||||
PROFILE="$HOME/.bash_profile"
|
|
||||||
elif [ -f "$HOME/.zshrc" ]; then
|
|
||||||
PROFILE="$HOME/.zshrc"
|
|
||||||
elif [ -f "$HOME/.profile" ]; then
|
|
||||||
PROFILE="$HOME/.profile"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
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."
|
|
||||||
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 lines to the correct file yourself:"
|
|
||||||
echo -e "$SOURCE_STR"
|
|
||||||
echo
|
echo
|
||||||
else
|
|
||||||
if ! grep -qc 'nvm.sh' $PROFILE; then
|
local NVM_PROFILE
|
||||||
echo "=> Appending source string to $PROFILE"
|
NVM_PROFILE=$(nvm_detect_profile)
|
||||||
echo -e "$SOURCE_STR" >> "$PROFILE"
|
|
||||||
|
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
|
||||||
|
|
||||||
|
if [ -z "$NVM_PROFILE" ] ; then
|
||||||
|
echo "=> Profile not found. Tried $NVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
|
||||||
|
echo "=> Create one of them and run this script again"
|
||||||
|
echo "=> Create it (touch $NVM_PROFILE) and run this script again"
|
||||||
|
echo " OR"
|
||||||
|
echo "=> Append the following lines to the correct file yourself:"
|
||||||
|
printf "$SOURCE_STR"
|
||||||
|
echo
|
||||||
else
|
else
|
||||||
echo "=> Source string already in $PROFILE"
|
if ! grep -qc 'nvm.sh' "$NVM_PROFILE"; then
|
||||||
|
echo "=> Appending source string to $NVM_PROFILE"
|
||||||
|
printf "$SOURCE_STR\n" >> "$NVM_PROFILE"
|
||||||
|
else
|
||||||
|
echo "=> Source string already in $NVM_PROFILE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
echo "=> Close and reopen your terminal to start using nvm"
|
echo "=> Close and reopen your terminal to start using nvm"
|
||||||
|
nvm_reset
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Unsets the various functions defined
|
||||||
|
# during the execution of the install script
|
||||||
|
#
|
||||||
|
nvm_reset() {
|
||||||
|
unset -f nvm_do_install nvm_has nvm_download install_nvm_as_script install_nvm_from_git nvm_reset nvm_detect_profile nvm_latest_version
|
||||||
|
}
|
||||||
|
|
||||||
|
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install
|
||||||
|
|||||||
16
package.json
16
package.json
@@ -1,14 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.8.0",
|
"version": "0.22.2",
|
||||||
"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"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "urchin test",
|
"test": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make test-$shell",
|
||||||
"test/fast": "urchin -f test/fast",
|
"test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=fast test-$shell",
|
||||||
"test/slow": "urchin -f test/slow"
|
"test/slow": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=slow test-$shell",
|
||||||
|
"test/install_script": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=install_script test-$shell",
|
||||||
|
"test/installation": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation test-$shell",
|
||||||
|
"test/sourcing": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=sourcing test-$shell"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -27,7 +30,8 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/creationix/nvm",
|
"homepage": "https://github.com/creationix/nvm",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"urchin": "~0.0.2"
|
"replace": "~0.3.0",
|
||||||
|
"semver": "~4.2.0",
|
||||||
|
"urchin": "~0.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
[ $(nvm alias test1 | wc -l) = '2' ]
|
[ $(nvm alias test-stable-1 | wc -l) = '2' ]
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||||
|
|
||||||
|
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||||
|
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_STABLE (-> $STABLE_VERSION) (default)$" \
|
||||||
|
|| die "nvm alias did not contain the default local stable node version"
|
||||||
|
|
||||||
|
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||||
|
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION) (default)$" \
|
||||||
|
|| die "nvm alias did not contain the default local unstable node version"
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
cleanup () {
|
||||||
|
rm -rf ../../../alias/stable
|
||||||
|
rm -rf ../../../alias/unstable
|
||||||
|
rm -rf ../../../v0.8.1
|
||||||
|
rm -rf ../../../v0.9.1
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir ../../../v0.8.1
|
||||||
|
mkdir ../../../v0.9.1
|
||||||
|
|
||||||
|
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||||
|
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||||
|
|
||||||
|
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||||
|
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||||
|
|
||||||
|
[ "_$STABLE_VERSION" != "_$UNSTABLE_VERSION" ] \
|
||||||
|
|| die "stable and unstable versions are the same!"
|
||||||
|
|
||||||
|
nvm alias stable "$EXPECTED_UNSTABLE"
|
||||||
|
nvm alias unstable "$EXPECTED_STABLE"
|
||||||
|
|
||||||
|
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||||
|
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \
|
||||||
|
|| die "nvm alias did not contain the overridden 'stable' alias"
|
||||||
|
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \
|
||||||
|
|| die "nvm alias did not contain the overridden 'unstable' alias"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
@@ -1,4 +1,48 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
[ $(nvm alias | wc -l) = '10' ]
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-1 -> 0.0.1 (-> v0.0.1)$' \
|
||||||
|
|| die "did not find test-stable-1 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-2 -> 0.0.2 (-> v0.0.2)$' \
|
||||||
|
|| die "did not find test-stable-2 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-3 -> 0.0.3 (-> v0.0.3)$' \
|
||||||
|
|| die "did not find test-stable-3 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-4 -> 0.0.4 (-> v0.0.4)$' \
|
||||||
|
|| die "did not find test-stable-4 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-5 -> 0.0.5 (-> v0.0.5)$' \
|
||||||
|
|| die "did not find test-stable-5 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-6 -> 0.0.6 (-> v0.0.6)$' \
|
||||||
|
|| die "did not find test-stable-6 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-7 -> 0.0.7 (-> v0.0.7)$' \
|
||||||
|
|| die "did not find test-stable-7 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-8 -> 0.0.8 (-> v0.0.8)$' \
|
||||||
|
|| die "did not find test-stable-8 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-9 -> 0.0.9 (-> v0.0.9)$' \
|
||||||
|
|| die "did not find test-stable-9 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-stable-10 -> 0.0.10 (-> v0.0.10)$' \
|
||||||
|
|| die "did not find test-stable-10 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-1 -> 0.1.1 (-> v0.1.1)$' \
|
||||||
|
|| die "did not find test-unstable-1 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-2 -> 0.1.2 (-> v0.1.2)$' \
|
||||||
|
|| die "did not find test-unstable-2 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-3 -> 0.1.3 (-> v0.1.3)$' \
|
||||||
|
|| die "did not find test-unstable-3 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-4 -> 0.1.4 (-> v0.1.4)$' \
|
||||||
|
|| die "did not find test-unstable-4 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-5 -> 0.1.5 (-> v0.1.5)$' \
|
||||||
|
|| die "did not find test-unstable-5 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-6 -> 0.1.6 (-> v0.1.6)$' \
|
||||||
|
|| die "did not find test-unstable-6 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-7 -> 0.1.7 (-> v0.1.7)$' \
|
||||||
|
|| die "did not find test-unstable-7 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-8 -> 0.1.8 (-> v0.1.8)$' \
|
||||||
|
|| die "did not find test-unstable-8 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-9 -> 0.1.9 (-> v0.1.9)$' \
|
||||||
|
|| die "did not find test-unstable-9 alias"
|
||||||
|
echo "$NVM_ALIAS_OUTPUT" | \grep -e '^test-unstable-10 -> 0.1.10 (-> v0.1.10)$' \
|
||||||
|
|| die "did not find test-unstable-10 alias"
|
||||||
|
|
||||||
|
|||||||
36
test/fast/Aliases/circular/nvm_resolve_alias
Executable file
36
test/fast/Aliases/circular/nvm_resolve_alias
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../../nvm.sh
|
||||||
|
|
||||||
|
ALIAS="$(nvm_resolve_alias loopback)"
|
||||||
|
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias loopback was not ∞; got $ALIAS"
|
||||||
|
OUTPUT="$(nvm alias loopback)"
|
||||||
|
EXPECTED_OUTPUT="loopback -> loopback (-> ∞)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias loopback was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
ALIAS="$(nvm_resolve_alias one)"
|
||||||
|
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias one was not ∞; got $ALIAS"
|
||||||
|
OUTPUT="$(nvm alias one)"
|
||||||
|
EXPECTED_OUTPUT="one -> two (-> ∞)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias one was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
ALIAS="$(nvm_resolve_alias two)"
|
||||||
|
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias two was not ∞; got $ALIAS"
|
||||||
|
OUTPUT="$(nvm alias two)"
|
||||||
|
EXPECTED_OUTPUT="two -> three (-> ∞)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias two was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
ALIAS="$(nvm_resolve_alias three)"
|
||||||
|
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias three was not ∞; got $ALIAS"
|
||||||
|
OUTPUT="$(nvm alias three)"
|
||||||
|
EXPECTED_OUTPUT="three -> one (-> ∞)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias three was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
ALIAS="$(nvm_resolve_alias four)"
|
||||||
|
[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_alias four was not ∞; got $ALIAS"
|
||||||
|
OUTPUT="$(nvm alias four)"
|
||||||
|
EXPECTED_OUTPUT="four -> two (-> ∞)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm alias four was not $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
10
test/fast/Aliases/circular/setup
Executable file
10
test/fast/Aliases/circular/setup
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo loopback > ../../../../alias/loopback
|
||||||
|
|
||||||
|
echo two > ../../../../alias/one
|
||||||
|
echo three > ../../../../alias/two
|
||||||
|
echo one > ../../../../alias/three
|
||||||
|
|
||||||
|
echo two > ../../../../alias/four
|
||||||
|
|
||||||
10
test/fast/Aliases/circular/teardown
Executable file
10
test/fast/Aliases/circular/teardown
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
rm -f ../../../../alias/loopback
|
||||||
|
|
||||||
|
rm -f ../../../../alias/one
|
||||||
|
rm -f ../../../../alias/two
|
||||||
|
rm -f ../../../../alias/three
|
||||||
|
|
||||||
|
rm -f ../../../../alias/four
|
||||||
|
|
||||||
28
test/fast/Aliases/nvm_resolve_alias
Executable file
28
test/fast/Aliases/nvm_resolve_alias
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
EXIT_CODE=$(nvm_resolve_alias ; echo $?)
|
||||||
|
[ $EXIT_CODE = "1" ] || die "nvm_resolve_alias without an argument did not return 1; got $EXIT_CODE"
|
||||||
|
|
||||||
|
for i in $(seq 1 10)
|
||||||
|
do
|
||||||
|
STABLE_ALIAS="$(nvm_resolve_alias test-stable-$i)"
|
||||||
|
[ "_$STABLE_ALIAS" = "_v0.0.$i" ] \
|
||||||
|
|| die "'nvm_resolve_alias test-stable-$i' was not v0.0.$i; got $STABLE_ALIAS"
|
||||||
|
UNSTABLE_ALIAS="$(nvm_resolve_alias test-unstable-$i)"
|
||||||
|
[ "_$UNSTABLE_ALIAS" = "_v0.1.$i" ] \
|
||||||
|
|| die "'nvm_resolve_alias test-unstable-$i' was not v0.1.$i; got $UNSTABLE_ALIAS"
|
||||||
|
done
|
||||||
|
|
||||||
|
EXIT_CODE=$(nvm_resolve_alias nonexistent ; echo $?)
|
||||||
|
[ $EXIT_CODE = "2" ] || die "'nvm_resolve_alias nonexistent' did not return 2; got $EXIT_CODE"
|
||||||
|
|
||||||
|
STABLE="$(nvm_resolve_alias stable)"
|
||||||
|
[ "_$STABLE" = "_v0.0.10" ] || die "'nvm_resolve_alias stable' was not v0.0.10; got $STABLE"
|
||||||
|
|
||||||
|
UNSTABLE="$(nvm_resolve_alias unstable)"
|
||||||
|
[ "_$UNSTABLE" = "_v0.1.10" ] || die "'nvm_resolve_alias unstable' was not v0.1.10; got $UNSTABLE"
|
||||||
|
|
||||||
9
test/fast/Aliases/setup
Executable file
9
test/fast/Aliases/setup
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
for i in $(seq 1 10)
|
||||||
|
do
|
||||||
|
echo 0.0.$i > ../../../alias/test-stable-$i
|
||||||
|
mkdir -p ../../../v0.0.$i
|
||||||
|
echo 0.1.$i > ../../../alias/test-unstable-$i
|
||||||
|
mkdir -p ../../../v0.1.$i
|
||||||
|
done
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
for i in $(seq 1 10)
|
|
||||||
do
|
|
||||||
echo v0.0.$i > ../../../alias/test$i
|
|
||||||
done
|
|
||||||
13
test/fast/Aliases/teardown
Executable file
13
test/fast/Aliases/teardown
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
for i in $(seq 1 10)
|
||||||
|
do
|
||||||
|
rm -f "../../../alias/test-stable-$i"
|
||||||
|
rm -rf "../../../v0.0.$i"
|
||||||
|
rm -f "../../../alias/test-unstable-$i"
|
||||||
|
rm -rf "../../../v0.1.$i"
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -f "../../../alias/stable"
|
||||||
|
rm -f "../../../alias/unstable"
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir -p ../../../v0.0.2
|
||||||
|
mkdir -p ../../../v0.0.20
|
||||||
|
mkdir -p ../../../versions/node/v0.12.0
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
|
|
||||||
|
nvm which 0.0.2 || die "v0.0.2 not found"
|
||||||
|
NVM_BIN="$(nvm which 0.0.2)"
|
||||||
|
[ "_$NVM_BIN" = "_$(nvm_version_path v0.0.2)/bin/node" ] \
|
||||||
|
|| die "'nvm which 0.0.2' did not contain the correct path: got '$NVM_BIN'"
|
||||||
|
|
||||||
|
nvm which 0.0.20 || die "v0.0.20 not found"
|
||||||
|
NVM_BIN="$(nvm which 0.0.20)"
|
||||||
|
[ "_$NVM_BIN" = "_$(nvm_version_path v0.0.20)/bin/node" ] \
|
||||||
|
|| die "'nvm which 0.20.0' did not contain the correct path: got '$NVM_BIN'"
|
||||||
|
|
||||||
|
nvm which 0.12.0 || die "v0.0.20 not found"
|
||||||
|
NVM_BIN="$(nvm which 0.12.0)"
|
||||||
|
[ "_$NVM_BIN" = "_$(nvm_version_path v0.12.0)/bin/node" ] \
|
||||||
|
|| die "'nvm which 0.12.0' did not contain the correct path: got '$NVM_BIN'"
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm which nonexistent_version
|
||||||
|
[ "_$?" = "_1" ]
|
||||||
3
test/fast/Listing paths/teardown
Executable file
3
test/fast/Listing paths/teardown
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
rmdir ../../../v0.0.2 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.0.20 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.12.0 >/dev/null 2>&1
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.0.2
|
||||||
|
mkdir ../../../v0.0.20
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
|
|
||||||
|
nvm ls 0.0.2 | grep 'v0.0.2' > /dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo '"nvm ls 0.0.2" contained v0.0.2'
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm ls 0.0.2 | grep 'v0.0.20' > /dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
die '"nvm ls 0.0.2" contained v0.0.20'
|
||||||
|
fi
|
||||||
|
|
||||||
@@ -2,11 +2,40 @@
|
|||||||
|
|
||||||
mkdir ../../../v0.1.3
|
mkdir ../../../v0.1.3
|
||||||
mkdir ../../../v0.2.3
|
mkdir ../../../v0.2.3
|
||||||
|
mkdir ../../../v0.20.3
|
||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
# The result should contain only the appropriate version numbers.
|
# 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.2.3' > /dev/null
|
||||||
nvm ls 0.1 | grep v0.1.3 &&
|
if [ $? -eq 0 ]; then
|
||||||
nvm ls v0.2 | grep v0.2.3
|
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,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
mkdir ../../../v0.2.3
|
||||||
|
mkdir ../../../v0.3.3
|
||||||
|
|
||||||
|
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||||
|
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||||
|
|
||||||
|
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||||
|
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||||
|
|
||||||
|
nvm ls stable | \grep "$STABLE_VERSION" >/dev/null \
|
||||||
|
|| die "expected 'nvm ls stable' to give $STABLE_VERSION, got $(nvm ls stable)"
|
||||||
|
|
||||||
|
nvm ls unstable | \grep "$UNSTABLE_VERSION" >/dev/null \
|
||||||
|
|| die "expected 'nvm ls unstable' to give $UNSTABLE_VERSION, got $(nvm ls unstable)"
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.2
|
||||||
|
nvm alias stable 0.1
|
||||||
|
|
||||||
|
nvm ls stable | \grep -v "$STABLE_VERSION" >/dev/null \
|
||||||
|
|| die "'nvm ls stable' contained $STABLE_VERSION instead of v0.1.2"
|
||||||
|
nvm ls stable | \grep v0.1.2 >/dev/null \
|
||||||
|
|| die "'nvm ls stable' did not contain v0.1.2"
|
||||||
|
|
||||||
@@ -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 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'
|
||||||
|
|
||||||
11
test/fast/Listing versions/Running "nvm ls" should filter out "versions"
Executable file
11
test/fast/Listing versions/Running "nvm ls" should filter out "versions"
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.3
|
||||||
|
mkdir ../../../v0.2.3
|
||||||
|
mkdir -p ../../../versions/node
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ -z "$(nvm ls | \grep 'versions')" ]
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
|
|
||||||
@@ -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/node/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'
|
||||||
|
|
||||||
@@ -6,5 +6,6 @@ mkdir ../../../v0.1.2
|
|||||||
|
|
||||||
nvm ls v0.1 | grep v0.1.2 &&
|
nvm ls v0.1 | grep v0.1.2 &&
|
||||||
nvm ls v0.1.2 | grep v0.1.2 &&
|
nvm ls v0.1.2 | grep v0.1.2 &&
|
||||||
nvm ls v0.1. | grep N/A &&
|
nvm ls v0.1. | grep v0.1.2 &&
|
||||||
nvm ls v0.1.1 | grep N/A
|
nvm ls v0.1.1 | grep N/A
|
||||||
|
|
||||||
|
|||||||
17
test/fast/Listing versions/teardown
Executable file
17
test/fast/Listing versions/teardown
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
rmdir ../../../v0.0.1 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.0.2 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.0.3 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.0.9 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.0.20 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.1.2 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.1.3 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.2.3 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.3.1 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.3.3 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.3.9 >/dev/null 2>&1
|
||||||
|
rmdir ../../../v0.20.3 >/dev/null 2>&1
|
||||||
|
rmdir ../../../versions >/dev/null 2>&1
|
||||||
|
unalias nvm_has_system_node >/dev/null 2>&1
|
||||||
|
rm -f ../../../alias/stable >/dev/null 2>&1
|
||||||
|
rm -f ../../../alias/unstable >/dev/null 2>&1
|
||||||
|
|
||||||
@@ -3,4 +3,8 @@
|
|||||||
die () { echo $@ ; exit 1; }
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
. ../../nvm.sh
|
. ../../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'
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ die () { echo $@ ; exit 1; }
|
|||||||
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||||
|
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
nvm use v0.2.3 &&
|
nvm use v0.2.3 || 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"
|
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` != 0 ] || die "PATH not set up properly"
|
||||||
|
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
|
||||||
|
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
|
||||||
|
|
||||||
nvm deactivate &&
|
nvm deactivate || 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"
|
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` = 0 ] || die "PATH not cleaned properly"
|
||||||
|
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH not cleaned properly"
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
cleanup () {
|
||||||
|
rm -rf ../../v0.10.4
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir ../../v0.10.4
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
nvm deactivate >/dev/null 2>&1
|
||||||
|
|
||||||
|
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from=0.11 2>&1)"
|
||||||
|
EXPECTED_ERROR_MSG="If --reinstall-packages-from is provided, it must point to an installed version of node."
|
||||||
|
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|
||||||
|
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
|
||||||
|
|
||||||
|
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --reinstall-packages-from=0.11 >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "~$INSTALL_EXIT_CODE" = "~5" ] \
|
||||||
|
|| die ""nvm install --reinstall-packages-from" should exit with code 5 when given an uninstalled version, got $INSTALL_EXIT_CODE"
|
||||||
|
|
||||||
|
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from=0.10.5 2>&1)"
|
||||||
|
EXPECTED_ERROR_MSG="You can't reinstall global packages from the same version of node you're installing."
|
||||||
|
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|
||||||
|
|| die ""nvm install --reinstall-packages-from" should fail when given the same version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
|
||||||
|
|
||||||
|
INSTALL_EXIT_CODE="$(nvm install v0.10.5 --reinstall-packages-from=0.10.5 >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "~$INSTALL_EXIT_CODE" = "~4" ] \
|
||||||
|
|| die ""nvm install --reinstall-packages-from" should exit with code 4 when given the same version, got $INSTALL_EXIT_CODE"
|
||||||
|
|
||||||
22
test/fast/Running "nvm use foo" where "foo" is circular aborts
Executable file
22
test/fast/Running "nvm use foo" where "foo" is circular aborts
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -rf ../../alias/foo
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
echo 'foo' > ../../alias/foo
|
||||||
|
|
||||||
|
OUTPUT="$(nvm use foo 2>&1)"
|
||||||
|
EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|
||||||
|
|| die "'nvm use foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"
|
||||||
|
|
||||||
|
cleanup;
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
33
test/fast/Running "nvm use x" should create and change the "current" symlink
Executable file
33
test/fast/Running "nvm use x" should create and change the "current" symlink
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export NVM_SYMLINK_CURRENT=true
|
||||||
|
. ../../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,84 @@
|
|||||||
|
#!/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 >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=false!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=true
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent || echo >&2 "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT=true!"
|
||||||
|
registerExpectedSymlink $?
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=garbagevalue
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT contains a string!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=0
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=0!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=1
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=1!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
unset NVM_SYMLINK_CURRENT
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent && echo >&2 "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT has been unset (default behaviour)!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
[ ${TEST_FAILED} -ne 0 ] && echo "${TEST_COUNT} tested, ${TEST_PASSED} passed, ${TEST_FAILED} failed" && exit 1 || true
|
||||||
|
|
||||||
33
test/fast/Unit tests/nvm_alias
Executable file
33
test/fast/Unit tests/nvm_alias
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
rm -rf ../../../alias/test
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_alias 2>&1)"
|
||||||
|
EXPECTED_OUTPUT='An alias is required.'
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias' produced wrong output; got $OUTPUT"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm_alias >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] || die "'nvm_alias' exited with $EXIT_CODE, expected 1"
|
||||||
|
|
||||||
|
rm -rf ../../../alias/nonexistent
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_alias nonexistent 2>&1)"
|
||||||
|
EXPECTED_OUTPUT='Alias does not exist.'
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias nonexistent' produced wrong output; got $OUTPUT"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm_alias nonexistent >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_2" ] || die "'nvm_alias nonexistent' exited with $EXIT_CODE, expected 2"
|
||||||
|
|
||||||
|
EXPECTED_OUTPUT="0.10"
|
||||||
|
nvm alias test "$EXPECTED_OUTPUT" || die "'nvm alias test $EXPECTED_OUTPUT' failed"
|
||||||
|
OUTPUT="$(nvm_alias test)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias test' produced wrong output; got $OUTPUT"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
8
test/fast/Unit tests/nvm_alias_path
Executable file
8
test/fast/Unit tests/nvm_alias_path
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "_$(nvm_alias_path)" = "_$NVM_DIR/alias" ] || die "nvm_alias_path did not requrn correct location"
|
||||||
|
|
||||||
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
|
||||||
9
test/fast/Unit tests/nvm_ensure_version_prefix
Executable file
9
test/fast/Unit tests/nvm_ensure_version_prefix
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "_$(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"'
|
||||||
26
test/fast/Unit tests/nvm_find_up
Executable file
26
test/fast/Unit tests/nvm_find_up
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
setup() {
|
||||||
|
cleanup
|
||||||
|
mkdir -p tmp_nvm_find_up/a/b/c/d
|
||||||
|
touch tmp_nvm_find_up/test
|
||||||
|
touch tmp_nvm_find_up/a/b/c/test
|
||||||
|
}
|
||||||
|
cleanup () {
|
||||||
|
rm -rf tmp_nvm_find_up
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
TEST_DIR="$PWD"
|
||||||
|
|
||||||
|
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up" ] || die "failed to find 1 dir up"
|
||||||
|
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up" ] || die "failed to find 2 dirs up"
|
||||||
|
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b/c nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up/a/b/c" ] || die "failed to find in current dir"
|
||||||
|
[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b/c/d nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up/a/b/c" ] || die "failed to find 1 level up from current dir"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
14
test/fast/Unit tests/nvm_format_version
Executable file
14
test/fast/Unit tests/nvm_format_version
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_format_version 0.1.2)"
|
||||||
|
EXPECTED_OUTPUT="v0.1.2"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version 0.1.2 did not return $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_format_version 0.1)"
|
||||||
|
EXPECTED_OUTPUT="v0.1.0"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_format_version 0.1.0 did not return $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
20
test/fast/Unit tests/nvm_get_latest missing curl or wget
Executable file
20
test/fast/Unit tests/nvm_get_latest missing curl or wget
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f nvm_has
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm_has() { return 1 ; }
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_get_latest 2>&1)"
|
||||||
|
EXIT_CODE="$(nvm_get_latest >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_nvm needs curl or wget to proceed." ] \
|
||||||
|
|| die "no curl/wget did not report correct error message, got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] \
|
||||||
|
|| die "no curl/wget did not exit with code 1, got $EXIT_CODE"
|
||||||
|
|
||||||
|
cleanup
|
||||||
12
test/fast/Unit tests/nvm_has
Executable file
12
test/fast/Unit tests/nvm_has
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm_has cat && type cat > /dev/null || die 'nvm_has locates "cat" properly'
|
||||||
|
|
||||||
|
[ "~$(nvm_has foobarbaz 2>&1)" = "~" ] || die "nvm_has does not suppress error output"
|
||||||
|
|
||||||
|
! nvm_has foobarbaz && ! type foobarbaz >/dev/null 2>&1 || die "nvm_has does not return a nonzero exit code when not found"
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
32
test/fast/Unit tests/nvm_ls_current
Executable file
32
test/fast/Unit tests/nvm_ls_current
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
TEST_PWD=$(pwd)
|
||||||
|
TEST_DIR="$TEST_PWD/nvm_ls_current_tmp"
|
||||||
|
|
||||||
|
cleanup() { rm -rf "$TEST_DIR"; unset -f return_zero; unalias node; }
|
||||||
|
die () { echo $@ ; cleanup ; 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"'
|
||||||
|
|
||||||
|
rm -rf "$TEST_DIR"
|
||||||
|
mkdir "$TEST_DIR"
|
||||||
|
ln -s "$(command which which)" "$TEST_DIR/which"
|
||||||
|
ln -s "$(command 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'
|
||||||
|
|
||||||
|
alias node='node --harmony'
|
||||||
|
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version'
|
||||||
|
|
||||||
|
cleanup
|
||||||
485
test/fast/Unit tests/nvm_ls_remote
Executable file
485
test/fast/Unit tests/nvm_ls_remote
Executable file
@@ -0,0 +1,485 @@
|
|||||||
|
#!/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 'foo "v0.10.0'
|
||||||
|
echo 'foo "v0.10.0'
|
||||||
|
echo 'foo "v0.10.1'
|
||||||
|
echo 'foo "v0.10.1'
|
||||||
|
echo 'foo "v0.10.10'
|
||||||
|
echo 'foo "v0.10.10'
|
||||||
|
echo 'foo "v0.10.11'
|
||||||
|
echo 'foo "v0.10.11'
|
||||||
|
echo 'foo "v0.10.12'
|
||||||
|
echo 'foo "v0.10.12'
|
||||||
|
echo 'foo "v0.10.13'
|
||||||
|
echo 'foo "v0.10.13'
|
||||||
|
echo 'foo "v0.10.14'
|
||||||
|
echo 'foo "v0.10.14'
|
||||||
|
echo 'foo "v0.10.15'
|
||||||
|
echo 'foo "v0.10.15'
|
||||||
|
echo 'foo "v0.10.16'
|
||||||
|
echo 'foo "v0.10.16'
|
||||||
|
echo 'foo "v0.10.16'
|
||||||
|
echo 'foo "v0.10.16'
|
||||||
|
echo 'foo "v0.10.17'
|
||||||
|
echo 'foo "v0.10.17'
|
||||||
|
echo 'foo "v0.10.18'
|
||||||
|
echo 'foo "v0.10.18'
|
||||||
|
echo 'foo "v0.10.19'
|
||||||
|
echo 'foo "v0.10.19'
|
||||||
|
echo 'foo "v0.10.2'
|
||||||
|
echo 'foo "v0.10.2'
|
||||||
|
echo 'foo "v0.10.20'
|
||||||
|
echo 'foo "v0.10.20'
|
||||||
|
echo 'foo "v0.10.21'
|
||||||
|
echo 'foo "v0.10.21'
|
||||||
|
echo 'foo "v0.10.22'
|
||||||
|
echo 'foo "v0.10.22'
|
||||||
|
echo 'foo "v0.10.23'
|
||||||
|
echo 'foo "v0.10.23'
|
||||||
|
echo 'foo "v0.10.24'
|
||||||
|
echo 'foo "v0.10.24'
|
||||||
|
echo 'foo "v0.10.25'
|
||||||
|
echo 'foo "v0.10.25'
|
||||||
|
echo 'foo "v0.10.26'
|
||||||
|
echo 'foo "v0.10.26'
|
||||||
|
echo 'foo "v0.10.27'
|
||||||
|
echo 'foo "v0.10.27'
|
||||||
|
echo 'foo "v0.10.28'
|
||||||
|
echo 'foo "v0.10.28'
|
||||||
|
echo 'foo "v0.10.29'
|
||||||
|
echo 'foo "v0.10.29'
|
||||||
|
echo 'foo "v0.10.3'
|
||||||
|
echo 'foo "v0.10.3'
|
||||||
|
echo 'foo "v0.10.30'
|
||||||
|
echo 'foo "v0.10.30'
|
||||||
|
echo 'foo "v0.10.31'
|
||||||
|
echo 'foo "v0.10.31'
|
||||||
|
echo 'foo "v0.10.32'
|
||||||
|
echo 'foo "v0.10.32'
|
||||||
|
echo 'foo "v0.10.4'
|
||||||
|
echo 'foo "v0.10.4'
|
||||||
|
echo 'foo "v0.10.5'
|
||||||
|
echo 'foo "v0.10.5'
|
||||||
|
echo 'foo "v0.10.6'
|
||||||
|
echo 'foo "v0.10.6'
|
||||||
|
echo 'foo "v0.10.7'
|
||||||
|
echo 'foo "v0.10.7'
|
||||||
|
echo 'foo "v0.10.8'
|
||||||
|
echo 'foo "v0.10.8'
|
||||||
|
echo 'foo "v0.10.9'
|
||||||
|
echo 'foo "v0.10.9'
|
||||||
|
echo 'foo "v0.11.0'
|
||||||
|
echo 'foo "v0.11.0'
|
||||||
|
echo 'foo "v0.11.1'
|
||||||
|
echo 'foo "v0.11.1'
|
||||||
|
echo 'foo "v0.11.10'
|
||||||
|
echo 'foo "v0.11.10'
|
||||||
|
echo 'foo "v0.11.11'
|
||||||
|
echo 'foo "v0.11.11'
|
||||||
|
echo 'foo "v0.11.12'
|
||||||
|
echo 'foo "v0.11.12'
|
||||||
|
echo 'foo "v0.11.13'
|
||||||
|
echo 'foo "v0.11.13'
|
||||||
|
echo 'foo "v0.11.14'
|
||||||
|
echo 'foo "v0.11.14'
|
||||||
|
echo 'foo "v0.11.2'
|
||||||
|
echo 'foo "v0.11.2'
|
||||||
|
echo 'foo "v0.11.3'
|
||||||
|
echo 'foo "v0.11.3'
|
||||||
|
echo 'foo "v0.11.4'
|
||||||
|
echo 'foo "v0.11.4'
|
||||||
|
echo 'foo "v0.11.5'
|
||||||
|
echo 'foo "v0.11.5'
|
||||||
|
echo 'foo "v0.11.6'
|
||||||
|
echo 'foo "v0.11.6'
|
||||||
|
echo 'foo "v0.11.7'
|
||||||
|
echo 'foo "v0.11.7'
|
||||||
|
echo 'foo "v0.11.8'
|
||||||
|
echo 'foo "v0.11.8'
|
||||||
|
echo 'foo "v0.11.9'
|
||||||
|
echo 'foo "v0.11.9'
|
||||||
|
echo 'foo "v0.5.1'
|
||||||
|
echo 'foo "v0.5.1'
|
||||||
|
echo 'foo "v0.5.10'
|
||||||
|
echo 'foo "v0.5.10'
|
||||||
|
echo 'foo "v0.5.2'
|
||||||
|
echo 'foo "v0.5.2'
|
||||||
|
echo 'foo "v0.5.3'
|
||||||
|
echo 'foo "v0.5.3'
|
||||||
|
echo 'foo "v0.5.4'
|
||||||
|
echo 'foo "v0.5.4'
|
||||||
|
echo 'foo "v0.5.5'
|
||||||
|
echo 'foo "v0.5.5'
|
||||||
|
echo 'foo "v0.5.6'
|
||||||
|
echo 'foo "v0.5.6'
|
||||||
|
echo 'foo "v0.5.7'
|
||||||
|
echo 'foo "v0.5.7'
|
||||||
|
echo 'foo "v0.5.8'
|
||||||
|
echo 'foo "v0.5.8'
|
||||||
|
echo 'foo "v0.5.9'
|
||||||
|
echo 'foo "v0.5.9'
|
||||||
|
echo 'foo "v0.6.0'
|
||||||
|
echo 'foo "v0.6.0'
|
||||||
|
echo 'foo "v0.6.1'
|
||||||
|
echo 'foo "v0.6.1'
|
||||||
|
echo 'foo "v0.6.10'
|
||||||
|
echo 'foo "v0.6.10'
|
||||||
|
echo 'foo "v0.6.11'
|
||||||
|
echo 'foo "v0.6.11'
|
||||||
|
echo 'foo "v0.6.12'
|
||||||
|
echo 'foo "v0.6.12'
|
||||||
|
echo 'foo "v0.6.13'
|
||||||
|
echo 'foo "v0.6.13'
|
||||||
|
echo 'foo "v0.6.14'
|
||||||
|
echo 'foo "v0.6.14'
|
||||||
|
echo 'foo "v0.6.15'
|
||||||
|
echo 'foo "v0.6.15'
|
||||||
|
echo 'foo "v0.6.16'
|
||||||
|
echo 'foo "v0.6.16'
|
||||||
|
echo 'foo "v0.6.17'
|
||||||
|
echo 'foo "v0.6.17'
|
||||||
|
echo 'foo "v0.6.18'
|
||||||
|
echo 'foo "v0.6.18'
|
||||||
|
echo 'foo "v0.6.19'
|
||||||
|
echo 'foo "v0.6.19'
|
||||||
|
echo 'foo "v0.6.2'
|
||||||
|
echo 'foo "v0.6.2'
|
||||||
|
echo 'foo "v0.6.20'
|
||||||
|
echo 'foo "v0.6.20'
|
||||||
|
echo 'foo "v0.6.21'
|
||||||
|
echo 'foo "v0.6.21'
|
||||||
|
echo 'foo "v0.6.3'
|
||||||
|
echo 'foo "v0.6.3'
|
||||||
|
echo 'foo "v0.6.4'
|
||||||
|
echo 'foo "v0.6.4'
|
||||||
|
echo 'foo "v0.6.5'
|
||||||
|
echo 'foo "v0.6.5'
|
||||||
|
echo 'foo "v0.6.6'
|
||||||
|
echo 'foo "v0.6.6'
|
||||||
|
echo 'foo "v0.6.7'
|
||||||
|
echo 'foo "v0.6.7'
|
||||||
|
echo 'foo "v0.6.8'
|
||||||
|
echo 'foo "v0.6.8'
|
||||||
|
echo 'foo "v0.6.9'
|
||||||
|
echo 'foo "v0.6.9'
|
||||||
|
echo 'foo "v0.7.0'
|
||||||
|
echo 'foo "v0.7.0'
|
||||||
|
echo 'foo "v0.7.1'
|
||||||
|
echo 'foo "v0.7.1'
|
||||||
|
echo 'foo "v0.7.10'
|
||||||
|
echo 'foo "v0.7.10'
|
||||||
|
echo 'foo "v0.7.11'
|
||||||
|
echo 'foo "v0.7.11'
|
||||||
|
echo 'foo "v0.7.12'
|
||||||
|
echo 'foo "v0.7.12'
|
||||||
|
echo 'foo "v0.7.2'
|
||||||
|
echo 'foo "v0.7.2'
|
||||||
|
echo 'foo "v0.7.3'
|
||||||
|
echo 'foo "v0.7.3'
|
||||||
|
echo 'foo "v0.7.4'
|
||||||
|
echo 'foo "v0.7.4'
|
||||||
|
echo 'foo "v0.7.5'
|
||||||
|
echo 'foo "v0.7.5'
|
||||||
|
echo 'foo "v0.7.6'
|
||||||
|
echo 'foo "v0.7.6'
|
||||||
|
echo 'foo "v0.7.7'
|
||||||
|
echo 'foo "v0.7.7'
|
||||||
|
echo 'foo "v0.7.8'
|
||||||
|
echo 'foo "v0.7.8'
|
||||||
|
echo 'foo "v0.7.9'
|
||||||
|
echo 'foo "v0.7.9'
|
||||||
|
echo 'foo "v0.8.0'
|
||||||
|
echo 'foo "v0.8.0'
|
||||||
|
echo 'foo "v0.8.1'
|
||||||
|
echo 'foo "v0.8.1'
|
||||||
|
echo 'foo "v0.8.10'
|
||||||
|
echo 'foo "v0.8.10'
|
||||||
|
echo 'foo "v0.8.11'
|
||||||
|
echo 'foo "v0.8.11'
|
||||||
|
echo 'foo "v0.8.12'
|
||||||
|
echo 'foo "v0.8.12'
|
||||||
|
echo 'foo "v0.8.13'
|
||||||
|
echo 'foo "v0.8.13'
|
||||||
|
echo 'foo "v0.8.14'
|
||||||
|
echo 'foo "v0.8.14'
|
||||||
|
echo 'foo "v0.8.15'
|
||||||
|
echo 'foo "v0.8.15'
|
||||||
|
echo 'foo "v0.8.16'
|
||||||
|
echo 'foo "v0.8.16'
|
||||||
|
echo 'foo "v0.8.17'
|
||||||
|
echo 'foo "v0.8.17'
|
||||||
|
echo 'foo "v0.8.18'
|
||||||
|
echo 'foo "v0.8.18'
|
||||||
|
echo 'foo "v0.8.19'
|
||||||
|
echo 'foo "v0.8.19'
|
||||||
|
echo 'foo "v0.8.2'
|
||||||
|
echo 'foo "v0.8.2'
|
||||||
|
echo 'foo "v0.8.20'
|
||||||
|
echo 'foo "v0.8.20'
|
||||||
|
echo 'foo "v0.8.21'
|
||||||
|
echo 'foo "v0.8.21'
|
||||||
|
echo 'foo "v0.8.22'
|
||||||
|
echo 'foo "v0.8.22'
|
||||||
|
echo 'foo "v0.8.23'
|
||||||
|
echo 'foo "v0.8.23'
|
||||||
|
echo 'foo "v0.8.24'
|
||||||
|
echo 'foo "v0.8.24'
|
||||||
|
echo 'foo "v0.8.25'
|
||||||
|
echo 'foo "v0.8.25'
|
||||||
|
echo 'foo "v0.8.26'
|
||||||
|
echo 'foo "v0.8.26'
|
||||||
|
echo 'foo "v0.8.27'
|
||||||
|
echo 'foo "v0.8.27'
|
||||||
|
echo 'foo "v0.8.28'
|
||||||
|
echo 'foo "v0.8.28'
|
||||||
|
echo 'foo "v0.8.3'
|
||||||
|
echo 'foo "v0.8.3'
|
||||||
|
echo 'foo "v0.8.4'
|
||||||
|
echo 'foo "v0.8.4'
|
||||||
|
echo 'foo "v0.8.5'
|
||||||
|
echo 'foo "v0.8.5'
|
||||||
|
echo 'foo "v0.8.6'
|
||||||
|
echo 'foo "v0.8.6'
|
||||||
|
echo 'foo "v0.8.7'
|
||||||
|
echo 'foo "v0.8.7'
|
||||||
|
echo 'foo "v0.8.8'
|
||||||
|
echo 'foo "v0.8.8'
|
||||||
|
echo 'foo "v0.8.9'
|
||||||
|
echo 'foo "v0.8.9'
|
||||||
|
echo 'foo "v0.9.0'
|
||||||
|
echo 'foo "v0.9.0'
|
||||||
|
echo 'foo "v0.9.1'
|
||||||
|
echo 'foo "v0.9.1'
|
||||||
|
echo 'foo "v0.9.10'
|
||||||
|
echo 'foo "v0.9.10'
|
||||||
|
echo 'foo "v0.9.11'
|
||||||
|
echo 'foo "v0.9.11'
|
||||||
|
echo 'foo "v0.9.12'
|
||||||
|
echo 'foo "v0.9.12'
|
||||||
|
echo 'foo "v0.9.2'
|
||||||
|
echo 'foo "v0.9.2'
|
||||||
|
echo 'foo "v0.9.3'
|
||||||
|
echo 'foo "v0.9.3'
|
||||||
|
echo 'foo "v0.9.4'
|
||||||
|
echo 'foo "v0.9.4'
|
||||||
|
echo 'foo "v0.9.5'
|
||||||
|
echo 'foo "v0.9.5'
|
||||||
|
echo 'foo "v0.9.6'
|
||||||
|
echo 'foo "v0.9.6'
|
||||||
|
echo 'foo "v0.9.7'
|
||||||
|
echo 'foo "v0.9.7'
|
||||||
|
echo 'foo "v0.9.8'
|
||||||
|
echo 'foo "v0.9.8'
|
||||||
|
echo 'foo "v0.9.9'
|
||||||
|
echo 'foo "v0.9.9'
|
||||||
|
echo 'foo "v0.1.100'
|
||||||
|
echo 'foo "v0.1.100'
|
||||||
|
echo 'foo "v0.1.101'
|
||||||
|
echo 'foo "v0.1.101'
|
||||||
|
echo 'foo "v0.1.102'
|
||||||
|
echo 'foo "v0.1.102'
|
||||||
|
echo 'foo "v0.1.103'
|
||||||
|
echo 'foo "v0.1.103'
|
||||||
|
echo 'foo "v0.1.104'
|
||||||
|
echo 'foo "v0.1.104'
|
||||||
|
echo 'foo "v0.1.14'
|
||||||
|
echo 'foo "v0.1.14'
|
||||||
|
echo 'foo "v0.1.15'
|
||||||
|
echo 'foo "v0.1.15'
|
||||||
|
echo 'foo "v0.1.16'
|
||||||
|
echo 'foo "v0.1.16'
|
||||||
|
echo 'foo "v0.1.17'
|
||||||
|
echo 'foo "v0.1.17'
|
||||||
|
echo 'foo "v0.1.18'
|
||||||
|
echo 'foo "v0.1.18'
|
||||||
|
echo 'foo "v0.1.19'
|
||||||
|
echo 'foo "v0.1.19'
|
||||||
|
echo 'foo "v0.1.20'
|
||||||
|
echo 'foo "v0.1.20'
|
||||||
|
echo 'foo "v0.1.21'
|
||||||
|
echo 'foo "v0.1.21'
|
||||||
|
echo 'foo "v0.1.22'
|
||||||
|
echo 'foo "v0.1.22'
|
||||||
|
echo 'foo "v0.1.23'
|
||||||
|
echo 'foo "v0.1.23'
|
||||||
|
echo 'foo "v0.1.24'
|
||||||
|
echo 'foo "v0.1.24'
|
||||||
|
echo 'foo "v0.1.25'
|
||||||
|
echo 'foo "v0.1.25'
|
||||||
|
echo 'foo "v0.1.26'
|
||||||
|
echo 'foo "v0.1.26'
|
||||||
|
echo 'foo "v0.1.27'
|
||||||
|
echo 'foo "v0.1.27'
|
||||||
|
echo 'foo "v0.1.28'
|
||||||
|
echo 'foo "v0.1.28'
|
||||||
|
echo 'foo "v0.1.29'
|
||||||
|
echo 'foo "v0.1.29'
|
||||||
|
echo 'foo "v0.1.30'
|
||||||
|
echo 'foo "v0.1.30'
|
||||||
|
echo 'foo "v0.1.31'
|
||||||
|
echo 'foo "v0.1.31'
|
||||||
|
echo 'foo "v0.1.32'
|
||||||
|
echo 'foo "v0.1.32'
|
||||||
|
echo 'foo "v0.1.33'
|
||||||
|
echo 'foo "v0.1.33'
|
||||||
|
echo 'foo "v0.1.90'
|
||||||
|
echo 'foo "v0.1.90'
|
||||||
|
echo 'foo "v0.1.91'
|
||||||
|
echo 'foo "v0.1.91'
|
||||||
|
echo 'foo "v0.1.92'
|
||||||
|
echo 'foo "v0.1.92'
|
||||||
|
echo 'foo "v0.1.93'
|
||||||
|
echo 'foo "v0.1.93'
|
||||||
|
echo 'foo "v0.1.94'
|
||||||
|
echo 'foo "v0.1.94'
|
||||||
|
echo 'foo "v0.1.95'
|
||||||
|
echo 'foo "v0.1.95'
|
||||||
|
echo 'foo "v0.1.96'
|
||||||
|
echo 'foo "v0.1.96'
|
||||||
|
echo 'foo "v0.1.97'
|
||||||
|
echo 'foo "v0.1.97'
|
||||||
|
echo 'foo "v0.1.98'
|
||||||
|
echo 'foo "v0.1.98'
|
||||||
|
echo 'foo "v0.1.99'
|
||||||
|
echo 'foo "v0.1.99'
|
||||||
|
echo 'foo "v0.10.14'
|
||||||
|
echo 'foo "v0.10.14'
|
||||||
|
echo 'foo "v0.2.0'
|
||||||
|
echo 'foo "v0.2.0'
|
||||||
|
echo 'foo "v0.2.1'
|
||||||
|
echo 'foo "v0.2.1'
|
||||||
|
echo 'foo "v0.2.2'
|
||||||
|
echo 'foo "v0.2.2'
|
||||||
|
echo 'foo "v0.2.3'
|
||||||
|
echo 'foo "v0.2.3'
|
||||||
|
echo 'foo "v0.2.4'
|
||||||
|
echo 'foo "v0.2.4'
|
||||||
|
echo 'foo "v0.2.5'
|
||||||
|
echo 'foo "v0.2.5'
|
||||||
|
echo 'foo "v0.2.6'
|
||||||
|
echo 'foo "v0.2.6'
|
||||||
|
echo 'foo "v0.3.0'
|
||||||
|
echo 'foo "v0.3.0'
|
||||||
|
echo 'foo "v0.3.1'
|
||||||
|
echo 'foo "v0.3.1'
|
||||||
|
echo 'foo "v0.3.2'
|
||||||
|
echo 'foo "v0.3.2'
|
||||||
|
echo 'foo "v0.3.3'
|
||||||
|
echo 'foo "v0.3.3'
|
||||||
|
echo 'foo "v0.3.4'
|
||||||
|
echo 'foo "v0.3.4'
|
||||||
|
echo 'foo "v0.3.5'
|
||||||
|
echo 'foo "v0.3.5'
|
||||||
|
echo 'foo "v0.3.6'
|
||||||
|
echo 'foo "v0.3.6'
|
||||||
|
echo 'foo "v0.3.7'
|
||||||
|
echo 'foo "v0.3.7'
|
||||||
|
echo 'foo "v0.3.8'
|
||||||
|
echo 'foo "v0.3.8'
|
||||||
|
echo 'foo "v0.4.0'
|
||||||
|
echo 'foo "v0.4.0'
|
||||||
|
echo 'foo "v0.4.1'
|
||||||
|
echo 'foo "v0.4.1'
|
||||||
|
echo 'foo "v0.4.10'
|
||||||
|
echo 'foo "v0.4.10'
|
||||||
|
echo 'foo "v0.4.11'
|
||||||
|
echo 'foo "v0.4.11'
|
||||||
|
echo 'foo "v0.4.12'
|
||||||
|
echo 'foo "v0.4.12'
|
||||||
|
echo 'foo "v0.4.2'
|
||||||
|
echo 'foo "v0.4.2'
|
||||||
|
echo 'foo "v0.4.3'
|
||||||
|
echo 'foo "v0.4.3'
|
||||||
|
echo 'foo "v0.4.4'
|
||||||
|
echo 'foo "v0.4.4'
|
||||||
|
echo 'foo "v0.4.5'
|
||||||
|
echo 'foo "v0.4.5'
|
||||||
|
echo 'foo "v0.4.6'
|
||||||
|
echo 'foo "v0.4.6'
|
||||||
|
echo 'foo "v0.4.7'
|
||||||
|
echo 'foo "v0.4.7'
|
||||||
|
echo 'foo "v0.4.8'
|
||||||
|
echo 'foo "v0.4.8'
|
||||||
|
echo 'foo "v0.4.9'
|
||||||
|
echo 'foo "v0.4.9'
|
||||||
|
echo 'foo "v0.5.0'
|
||||||
|
echo 'foo "v0.5.0'
|
||||||
|
echo 'foo "v0.6.1'
|
||||||
|
echo 'foo "v0.6.1'
|
||||||
|
echo 'foo "v0.6.10'
|
||||||
|
echo 'foo "v0.6.10'
|
||||||
|
echo 'foo "v0.6.11'
|
||||||
|
echo 'foo "v0.6.11'
|
||||||
|
echo 'foo "v0.6.12'
|
||||||
|
echo 'foo "v0.6.12'
|
||||||
|
echo 'foo "v0.6.13'
|
||||||
|
echo 'foo "v0.6.13'
|
||||||
|
echo 'foo "v0.6.2'
|
||||||
|
echo 'foo "v0.6.2'
|
||||||
|
echo 'foo "v0.6.3'
|
||||||
|
echo 'foo "v0.6.3'
|
||||||
|
echo 'foo "v0.6.4'
|
||||||
|
echo 'foo "v0.6.4'
|
||||||
|
echo 'foo "v0.6.5'
|
||||||
|
echo 'foo "v0.6.5'
|
||||||
|
echo 'foo "v0.6.6'
|
||||||
|
echo 'foo "v0.6.6'
|
||||||
|
echo 'foo "v0.6.7'
|
||||||
|
echo 'foo "v0.6.7'
|
||||||
|
echo 'foo "v0.6.8'
|
||||||
|
echo 'foo "v0.6.8'
|
||||||
|
echo 'foo "v0.6.9'
|
||||||
|
echo 'foo "v0.6.9'
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_ls_remote foo)"
|
||||||
|
EXIT_CODE="$(nvm_ls_remote 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)"
|
||||||
|
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)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote did not output expected sorted versions; got $(echo "$OUTPUT") expected $(echo "$EXPECTED_OUTPUT")"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_ls_remote 0.3)"
|
||||||
|
EXPECTED_OUTPUT="v0.3.0
|
||||||
|
v0.3.1
|
||||||
|
v0.3.2
|
||||||
|
v0.3.3
|
||||||
|
v0.3.4
|
||||||
|
v0.3.5
|
||||||
|
v0.3.6
|
||||||
|
v0.3.7
|
||||||
|
v0.3.8"
|
||||||
|
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT"
|
||||||
|
|
||||||
|
# Sanity checks
|
||||||
|
OUTPUT="$(nvm_print_implicit_alias remote stable)"
|
||||||
|
EXPECTED_OUTPUT="0.10"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_print_implicit_alias remote unstable)"
|
||||||
|
EXPECTED_OUTPUT="0.11"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_ls_remote stable)"
|
||||||
|
EXPECTED_OUTPUT="v0.10.32"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_ls_remote unstable)"
|
||||||
|
EXPECTED_OUTPUT="v0.11.14"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
21
test/fast/Unit tests/nvm_num_version_groups
Executable file
21
test/fast/Unit tests/nvm_num_version_groups
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0"
|
||||||
|
[ "~$(nvm_num_version_groups a)" = "~1" ] || die "one letter should give 1"
|
||||||
|
|
||||||
|
[ "~$(nvm_num_version_groups 1)" = "~1" ] || die "1 should give 1"
|
||||||
|
[ "~$(nvm_num_version_groups v1)" = "~1" ] || die "v1 should give 1"
|
||||||
|
[ "~$(nvm_num_version_groups v1.)" = "~1" ] || die "v1. should give 1"
|
||||||
|
|
||||||
|
[ "~$(nvm_num_version_groups 1.2)" = "~2" ] || die "1.2 should give 2"
|
||||||
|
[ "~$(nvm_num_version_groups v1.2)" = "~2" ] || die "v1.2 should give 2"
|
||||||
|
[ "~$(nvm_num_version_groups v1.2.)" = "~2" ] || die "v1.2. should give 2"
|
||||||
|
|
||||||
|
[ "~$(nvm_num_version_groups 1.2.3)" = "~3" ] || die "1.2.3 should give 3"
|
||||||
|
[ "~$(nvm_num_version_groups v1.2.3)" = "~3" ] || die "v1.2.3 should give 3"
|
||||||
|
[ "~$(nvm_num_version_groups v1.2.3.)" = "~3" ] || die "v1.2.3. should give 3"
|
||||||
|
|
||||||
26
test/fast/Unit tests/nvm_print_implicit_alias errors
Executable file
26
test/fast/Unit tests/nvm_print_implicit_alias errors
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
EXPECTED_FIRST_MSG="nvm_print_implicit_alias must be specified with local or remote as the first argument."
|
||||||
|
[ "_$(nvm_print_implicit_alias 2>&1)" = "_$EXPECTED_FIRST_MSG" ] \
|
||||||
|
|| die "nvm_print_implicit_alias did not require local|remote as first argument"
|
||||||
|
[ "_$(nvm_print_implicit_alias foo 2>&1)" = "_$EXPECTED_FIRST_MSG" ] \
|
||||||
|
|| die "nvm_print_implicit_alias did not require local|remote as first argument"
|
||||||
|
|
||||||
|
FIRST_EXIT_CODE="$(nvm_print_implicit_alias > /dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$FIRST_EXIT_CODE" = "_1" ] \
|
||||||
|
|| die "nvm_print_implicit_alias without local|remote had wrong exit code: expected 1, got $FIRST_EXIT_CODE"
|
||||||
|
|
||||||
|
EXPECTED_SECOND_MSG="Only implicit aliases 'stable' and 'unstable' are supported."
|
||||||
|
[ "_$(nvm_print_implicit_alias local 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|
||||||
|
|| die "nvm_print_implicit_alias did not require stable|unstable as second argument"
|
||||||
|
[ "_$(nvm_print_implicit_alias local foo 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \
|
||||||
|
|| die "nvm_print_implicit_alias did not require stable|unstable as second argument"
|
||||||
|
|
||||||
|
SECOND_EXIT_CODE="$(nvm_print_implicit_alias local > /dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$SECOND_EXIT_CODE" = "_2" ] \
|
||||||
|
|| die "nvm_print_implicit_alias without stable|unstable had wrong exit code: expected 2, got $SECOND_EXIT_CODE"
|
||||||
|
|
||||||
47
test/fast/Unit tests/nvm_print_implicit_alias success
Executable file
47
test/fast/Unit tests/nvm_print_implicit_alias success
Executable file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
cleanup() {
|
||||||
|
rm -rf ../../../v0.2.3
|
||||||
|
rm -rf ../../../v0.3.4
|
||||||
|
rm -rf ../../../v0.4.6
|
||||||
|
rm -rf ../../../v0.5.7
|
||||||
|
rm -rf ../../../v0.7.7
|
||||||
|
unset -f nvm_ls_remote
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.2.3
|
||||||
|
mkdir ../../../v0.3.4
|
||||||
|
mkdir ../../../v0.4.6
|
||||||
|
mkdir ../../../v0.5.7
|
||||||
|
mkdir ../../../v0.7.7
|
||||||
|
|
||||||
|
LATEST_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||||
|
[ "_$LATEST_STABLE" = "_0.4" ] || die "local stable is not latest even minor: expected 0.4, got $LATEST_STABLE"
|
||||||
|
|
||||||
|
LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||||
|
[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest odd minor: expected 0.7, got $LATEST_UNSTABLE"
|
||||||
|
|
||||||
|
nvm_ls_remote() {
|
||||||
|
echo "v0.4.3"
|
||||||
|
echo "v0.5.4"
|
||||||
|
echo "v0.6.6"
|
||||||
|
echo "v0.7.7"
|
||||||
|
echo "v0.9.7"
|
||||||
|
echo "v0.4.3"
|
||||||
|
echo "v0.5.4"
|
||||||
|
echo "v0.6.6"
|
||||||
|
echo "v0.7.7"
|
||||||
|
echo "v0.9.7"
|
||||||
|
}
|
||||||
|
|
||||||
|
LATEST_STABLE="$(nvm_print_implicit_alias remote stable)"
|
||||||
|
[ "_$LATEST_STABLE" = "_0.6" ] || die "remote stable is not latest even minor: expected 0.6, got $LATEST_STABLE"
|
||||||
|
|
||||||
|
LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)"
|
||||||
|
[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd minor: expected 0.9, got $LATEST_UNSTABLE"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
35
test/fast/Unit tests/nvm_remote_version
Executable file
35
test/fast/Unit tests/nvm_remote_version
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f nvm_ls_remote
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../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() {
|
||||||
|
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"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
19
test/fast/Unit tests/nvm_validate_implicit_alias
Executable file
19
test/fast/Unit tests/nvm_validate_implicit_alias
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
EXPECTED_MSG="Only implicit aliases 'stable' and 'unstable' are supported."
|
||||||
|
[ "_$(nvm_validate_implicit_alias 2>&1)" = "_$EXPECTED_MSG" ] \
|
||||||
|
|| die "nvm_validate_implicit_alias did not require stable|unstable"
|
||||||
|
[ "_$(nvm_validate_implicit_alias foo 2>&1)" = "_$EXPECTED_MSG" ] \
|
||||||
|
|| die "nvm_validate_implicit_alias did not require stable|unstable"
|
||||||
|
|
||||||
|
EXIT_CODE="$(nvm_validate_implicit_alias >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$EXIT_CODE" = "_1" ] \
|
||||||
|
|| die "nvm_validate_implicit_alias without stable|unstable had wrong exit code: expected 1, got $EXIT_CODE"
|
||||||
|
|
||||||
|
nvm_validate_implicit_alias stable || die "nvm_validate_implicit_alias stable did not exit 0"
|
||||||
|
nvm_validate_implicit_alias unstable || die "nvm_validate_implicit_alias unstable did not exit 0"
|
||||||
|
|
||||||
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/node" ] || 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/node/v0.12.0" ] || die 'new version has the wrong path'
|
||||||
|
|
||||||
@@ -9,5 +9,8 @@
|
|||||||
for SRC in v* src alias; do
|
for SRC in v* src alias; do
|
||||||
[ -e "$SRC" ] && mv "$SRC" bak
|
[ -e "$SRC" ] && mv "$SRC" bak
|
||||||
done
|
done
|
||||||
|
if [ -d versions ]; then
|
||||||
|
mv versions bak
|
||||||
|
fi
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|||||||
67
test/install_script/nvm_detect_profile
Executable file
67
test/install_script/nvm_detect_profile
Executable file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
unset -f setup cleanup die
|
||||||
|
unset _PROFILE
|
||||||
|
rm -f .bashrc .bash_profile .zshrc .profile test_profile > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
NVM_ENV=testing . ../../install.sh
|
||||||
|
|
||||||
|
setup () {
|
||||||
|
touch .bashrc
|
||||||
|
touch .bash_profile
|
||||||
|
touch .zshrc
|
||||||
|
touch .profile
|
||||||
|
touch test_profile
|
||||||
|
}
|
||||||
|
|
||||||
|
#Let's hack $HOME
|
||||||
|
HOME="."
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
|
||||||
|
# $PROFILE points to a valid file, its path must be returned
|
||||||
|
PROFILE="test_profile"
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$PROFILE" ] || die "nvm_detect_profile didn't pick \$PROFILE"
|
||||||
|
|
||||||
|
# $PROFILE doesn't point to a valid file, its path must not be returned
|
||||||
|
PROFILE="invalid_profile"
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" != "_$PROFILE" ] || die "nvm_detect_profile shouldn't pick \$PROFILE when it's not a valid file"
|
||||||
|
|
||||||
|
|
||||||
|
# Below are tests for when $PROFILE is undefined
|
||||||
|
rm test_profile
|
||||||
|
unset PROFILE
|
||||||
|
|
||||||
|
# It should favor .bashrc if file exists
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$HOME/.bashrc" ] || die "nvm_detect_profile should have selected .bashrc"
|
||||||
|
|
||||||
|
rm .bashrc
|
||||||
|
# Otherwise, it should favor .bash_profile if file exists
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$HOME/.bash_profile" ] || die "nvm_detect_profile should have selected .bash_profile"
|
||||||
|
|
||||||
|
rm .bash_profile
|
||||||
|
# Otherwise, it should favor .zshrc if file exists
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$HOME/.zshrc" ] || die "nvm_detect_profile should have selected .zshrc"
|
||||||
|
|
||||||
|
rm .zshrc
|
||||||
|
# Otherwise, it should favor .profile if file exists
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ "_$_PROFILE" = "_$HOME/.profile" ] || die "nvm_detect_profile should have selected .profile"
|
||||||
|
|
||||||
|
rm .profile
|
||||||
|
# It should be empty if none is found
|
||||||
|
_PROFILE=$(nvm_detect_profile)
|
||||||
|
[ -z "$_PROFILE" ] || die "nvm_detect_profile should have echo'ed an empty value"
|
||||||
|
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
9
test/install_script/nvm_do_install
Executable file
9
test/install_script/nvm_do_install
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
NVM_ENV=testing . ../../install.sh
|
||||||
|
|
||||||
|
#nvm_do_install is available
|
||||||
|
type nvm_do_install > /dev/null 2>&1 || die 'nvm_do_install is not available'
|
||||||
|
|
||||||
30
test/install_script/nvm_reset
Executable file
30
test/install_script/nvm_reset
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
unset -f safe_type die cleanup
|
||||||
|
}
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
NVM_ENV=testing . ../../install.sh
|
||||||
|
|
||||||
|
safe_type() {
|
||||||
|
type "$1" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check nvm_reset exists
|
||||||
|
safe_type nvm_reset || die 'nvm_reset is not available'
|
||||||
|
|
||||||
|
# Apply nvm_reset
|
||||||
|
nvm_reset
|
||||||
|
|
||||||
|
# The names should be unset
|
||||||
|
! safe_type nvm_do_install || die 'nvm_do_install is still available'
|
||||||
|
! safe_type nvm_has || die 'nvm_has is still available'
|
||||||
|
! safe_type nvm_download || die 'nvm_download is still available'
|
||||||
|
! safe_type install_nvm_as_script || die 'install_nvm_as_script is still available'
|
||||||
|
! safe_type install_nvm_from_git || die 'install_nvm_from_git is still available'
|
||||||
|
! safe_type nvm_reset || die 'nvm_reset is still available'
|
||||||
|
! safe_type nvm_detect_profile || die 'nvm_detect_profile is still available'
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
40
test/install_script/nvm_source
Executable file
40
test/install_script/nvm_source
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
unset -f die cleanup
|
||||||
|
unset NVM_SOURCE out
|
||||||
|
}
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
NVM_ENV=testing . ../../install.sh
|
||||||
|
|
||||||
|
# nvm_source with no parameter returns the git endpoint
|
||||||
|
echo $(nvm_source) | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo"
|
||||||
|
|
||||||
|
# nvm_source with git parameter returns the location of the nvm repo
|
||||||
|
echo $(nvm_source "git") | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo"
|
||||||
|
|
||||||
|
# nvm_source with script parameter returns the location of nvm.sh
|
||||||
|
echo $(nvm_source "script") | grep "nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh"
|
||||||
|
|
||||||
|
# nvm_source with script-nvm-exec parameter returns the location of nvm-exec
|
||||||
|
echo $(nvm_source "script-nvm-exec") | grep "nvm-exec$" > /dev/null || die "nvm_source \"script-nvm-exec\" should return the location of nvm.sh"
|
||||||
|
|
||||||
|
# nvm_source with any other parameter errors out and exits
|
||||||
|
nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit"
|
||||||
|
out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here
|
||||||
|
[ -z "$out" ] && die "nvm_source with invalid parameter should error out"
|
||||||
|
|
||||||
|
#nvm_source should always return NVM_SOURCE no matter the parameters
|
||||||
|
NVM_SOURCE="my_location"
|
||||||
|
out=$(nvm_source)
|
||||||
|
[ "_$out" = "_my_location" ] || die "nvm_source without arguments should have returned \$NVM_SOURCE. Got \"$out\""
|
||||||
|
out=$(nvm_source "git")
|
||||||
|
[ "_$out" = "_my_location" ] || die "nvm_source git should have returned \$NVM_SOURCE. Got \"$out\""
|
||||||
|
out=$(nvm_source "script")
|
||||||
|
[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""
|
||||||
|
out=$(nvm_source "anything")
|
||||||
|
[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""
|
||||||
|
|
||||||
|
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
|
||||||
18
test/installation/install from binary
Executable file
18
test/installation/install from binary
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install $NVM_TEST_VERSION || die "install $NVM_TEST_VERSION failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../$NVM_TEST_VERSION ]
|
||||||
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
18
test/installation/install from source
Executable file
18
test/installation/install from source
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from source
|
||||||
|
nvm install -s $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../$NVM_TEST_VERSION ]
|
||||||
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
25
test/installation/install two versions and use the latest one
Executable file
25
test/installation/install two versions and use the latest one
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
# 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 || die "'nvm install 0.9.7' failed"
|
||||||
|
nvm i 0.9.12 || die "'nvm i 0.9.12' failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../v0.9.7 ] || die "v0.9.7 didn't exist"
|
||||||
|
[ -d ../../v0.9.12 ] || die "v0.9.12 didn't exist"
|
||||||
|
|
||||||
|
# Use the first one
|
||||||
|
nvm use 0.9.7 || die "'nvm use 0.9.7' failed"
|
||||||
|
|
||||||
|
# Use the latest one
|
||||||
|
nvm use 0.9 || die "'nvm use 0.9' failed"
|
||||||
|
node --version | grep v0.9.12 || die "'node --version' was not v0.9.12, got: $(node --version)"
|
||||||
|
|
||||||
22
test/installation/install version specified in .nvmrc from binary
Executable file
22
test/installation/install version specified in .nvmrc from binary
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
echo "$NVM_TEST_VERSION" > .nvmrc
|
||||||
|
|
||||||
|
nvm install || die "'nvm install' failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../$NVM_TEST_VERSION ] || die "./$NVM_TEST_VERSION did not exist"
|
||||||
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION \
|
||||||
|
|| "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
|
|
||||||
22
test/installation/install version specified in .nvmrc from source
Executable file
22
test/installation/install version specified in .nvmrc from source
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
echo "$NVM_TEST_VERSION" > .nvmrc
|
||||||
|
|
||||||
|
nvm install -s || "'nvm install -s' failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../$NVM_TEST_VERSION ] || die "$NVM_TEST_VERSION did not exist"
|
||||||
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION \
|
||||||
|
|| die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"
|
||||||
|
|
||||||
|
|
||||||
34
test/installation/install while reinstalling packages
Executable file
34
test/installation/install while reinstalling packages
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../v0.9.7 ] || die "nvm install 0.9.7 didn't install"
|
||||||
|
|
||||||
|
nvm use 0.9.7
|
||||||
|
|
||||||
|
node --version | grep v0.9.7 > /dev/null || die "nvm use 0.9.7 failed"
|
||||||
|
|
||||||
|
npm install -g is-nan@1.0.1 || die "npm install -g is-nan failed"
|
||||||
|
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||||
|
|
||||||
|
nvm ls 0.9 | grep v0.9.7 > /dev/null || die "nvm ls 0.9 didn't show v0.9.7"
|
||||||
|
|
||||||
|
nvm install 0.9.12 --reinstall-packages-from=0.9 || die "nvm install 0.9.12 --reinstall-packages-from=0.9 failed"
|
||||||
|
|
||||||
|
[ -d ../../v0.9.12 ] || die "nvm install 0.9.12 didn't install"
|
||||||
|
|
||||||
|
nvm use 0.9
|
||||||
|
node --version | grep v0.9.12 > /dev/null || die "nvm ls 0.9 didn't use v0.9.12"
|
||||||
|
|
||||||
|
npm list --global | grep is-nan > /dev/null || die "is-nan isn't installed"
|
||||||
|
|
||||||
117
test/installation/nvm_get_latest/nvm_get_latest
Executable file
117
test/installation/nvm_get_latest/nvm_get_latest
Executable file
@@ -0,0 +1,117 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f curl wget nvm_has
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
EXPECTED_VERSION="v12.3.456"
|
||||||
|
URL="https://github.com/creationix/nvm/releases/tag/$EXPECTED_VERSION"
|
||||||
|
EXPECTED_CURL_ARGS="-w %{url_effective}\n -L -s -S http://latest.nvm.sh -o /dev/null"
|
||||||
|
EXPECTED_WGET_ARGS="http://latest.nvm.sh --server-response -O /dev/null"
|
||||||
|
|
||||||
|
curl() {
|
||||||
|
if [ "_$*" != "_$EXPECTED_CURL_ARGS" ]; then
|
||||||
|
echo 2>& "expected args ($EXPECTED_CURL_ARGS), got ($*)"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo $URL
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
wget() {
|
||||||
|
if [ "_$*" != "_$EXPECTED_WGET_ARGS" ]; then
|
||||||
|
echo 2>& "expected args ($EXPECTED_WGET_ARGS), got ($*)"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
local WGET_CONTENTS
|
||||||
|
WGET_CONTENTS="
|
||||||
|
--2014-12-21 18:11:14-- http://latest.nvm.sh/
|
||||||
|
Resolving latest.nvm.sh... 50.31.209.229
|
||||||
|
Connecting to latest.nvm.sh|50.31.209.229|:80... connected.
|
||||||
|
HTTP request sent, awaiting response...
|
||||||
|
HTTP/1.1 301 Moved Permanently
|
||||||
|
Location: https://github.com/creationix/nvm/releases/latest
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Content-Length: 84
|
||||||
|
Date: Mon, 22 Dec 2014 02:11:15 GMT
|
||||||
|
Location: https://github.com/creationix/nvm/releases/latest [following]
|
||||||
|
--2014-12-21 18:11:15-- https://github.com/creationix/nvm/releases/latest
|
||||||
|
Resolving github.com... 192.30.252.130
|
||||||
|
Connecting to github.com|192.30.252.130|:443... connected.
|
||||||
|
HTTP request sent, awaiting response...
|
||||||
|
HTTP/1.1 302 Found
|
||||||
|
Server: GitHub.com
|
||||||
|
Date: Mon, 22 Dec 2014 02:11:15 GMT
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Transfer-Encoding: chunked
|
||||||
|
Status: 302 Found
|
||||||
|
X-XSS-Protection: 1; mode=block
|
||||||
|
X-Frame-Options: deny
|
||||||
|
Content-Security-Policy: default-src *; script-src assets-cdn.github.com collector-cdn.github.com; object-src assets-cdn.github.com; style-src 'self' 'unsafe-inline' 'unsafe-eval' assets-cdn.github.com; img-src 'self' data: assets-cdn.github.com identicons.github.com www.google-analytics.com collector.githubapp.com *.githubusercontent.com *.gravatar.com *.wp.com; media-src 'none'; frame-src 'self' render.githubusercontent.com gist.github.com www.youtube.com player.vimeo.com checkout.paypal.com; font-src assets-cdn.github.com; connect-src 'self' ghconduit.com:25035 live.github.com uploads.github.com www.google-analytics.com s3.amazonaws.com
|
||||||
|
Cache-Control: no-cache
|
||||||
|
Vary: X-PJAX
|
||||||
|
Location: $URL
|
||||||
|
X-UA-Compatible: IE=Edge,chrome=1
|
||||||
|
Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Fri, 22-Dec-2034 02:11:15 GMT; secure; HttpOnly
|
||||||
|
Set-Cookie: _gh_sess=eyJzZXNzaW9uX2lkIjoiNTMzNGNjZWUxM2VhZjNhN2M3MzIwZWUxNGYwNzhmNDkiLCJzcHlfcmVwbyI6ImNyZWF0aW9uaXgvbnZtIiwic3B5X3JlcG9fYXQiOjE0MTkyMTQyNzV9--e2fa4cf5305d61aa58c0e0bf21fdb335a9660dcf; path=/; secure; HttpOnly
|
||||||
|
X-Request-Id: 4b99bf200157dd845f76ab83e4093acc
|
||||||
|
X-Runtime: 0.030872
|
||||||
|
X-Rack-Cache: miss
|
||||||
|
X-GitHub-Request-Id: 45B56780:3913:880EF6:54977DC3
|
||||||
|
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
|
||||||
|
X-Content-Type-Options: nosniff
|
||||||
|
Vary: Accept-Encoding
|
||||||
|
X-Served-By: ef97014f01ea59c1ef337fe51a4d0331
|
||||||
|
Location: $URL [following]
|
||||||
|
--2014-12-21 18:11:15-- $URL
|
||||||
|
Reusing existing connection to github.com:443.
|
||||||
|
HTTP request sent, awaiting response...
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Server: GitHub.com
|
||||||
|
Date: Mon, 22 Dec 2014 02:11:15 GMT
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Transfer-Encoding: chunked
|
||||||
|
Status: 200 OK
|
||||||
|
X-XSS-Protection: 1; mode=block
|
||||||
|
X-Frame-Options: deny
|
||||||
|
Content-Security-Policy: default-src *; script-src assets-cdn.github.com collector-cdn.github.com; object-src assets-cdn.github.com; style-src 'self' 'unsafe-inline' 'unsafe-eval' assets-cdn.github.com; img-src 'self' data: assets-cdn.github.com identicons.github.com www.google-analytics.com collector.githubapp.com *.githubusercontent.com *.gravatar.com *.wp.com; media-src 'none'; frame-src 'self' render.githubusercontent.com gist.github.com www.youtube.com player.vimeo.com checkout.paypal.com; font-src assets-cdn.github.com; connect-src 'self' ghconduit.com:25035 live.github.com uploads.github.com www.google-analytics.com s3.amazonaws.com
|
||||||
|
Cache-Control: no-cache, private
|
||||||
|
Vary: X-PJAX
|
||||||
|
X-UA-Compatible: IE=Edge,chrome=1
|
||||||
|
Set-Cookie: _gh_sess=eyJzZXNzaW9uX2lkIjoiNTMzNGNjZWUxM2VhZjNhN2M3MzIwZWUxNGYwNzhmNDkiLCJzcHlfcmVwbyI6ImNyZWF0aW9uaXgvbnZtIiwic3B5X3JlcG9fYXQiOjE0MTkyMTQyNzUsIl9jc3JmX3Rva2VuIjoiemZTVDNIRGo0QzF0dzkyNXp6NFBRdGJVbTl4NSsxTGo1cngwVFQ3NDVwdz0ifQ%3D%3D--b72bfd5241907dcf557b226e74351ff39f0e9ede; path=/; secure; HttpOnly
|
||||||
|
X-Request-Id: 305b0d158bf8c0b3fa488a33d7687091
|
||||||
|
X-Runtime: 0.038544
|
||||||
|
X-Rack-Cache: miss
|
||||||
|
X-GitHub-Request-Id: 45B56780:3913:880F19:54977DC3
|
||||||
|
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
|
||||||
|
X-Content-Type-Options: nosniff
|
||||||
|
Vary: Accept-Encoding
|
||||||
|
X-Served-By: 926b734ea1992f8ee1f88ab967a93dac
|
||||||
|
Length: unspecified [text/html]
|
||||||
|
Saving to: ‘/dev/null’
|
||||||
|
|
||||||
|
0K .......... ......... 225K=0.09s
|
||||||
|
|
||||||
|
2014-12-21 18:11:15 (225 KB/s) - ‘/dev/null’ saved [20298]
|
||||||
|
|
||||||
|
"
|
||||||
|
"$WGET_CONTENTS" | while read line
|
||||||
|
do
|
||||||
|
2>& echo "$line"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_get_latest)"
|
||||||
|
EXIT_CODE="$(nvm_get_latest >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_VERSION" ] \
|
||||||
|
|| die "success path did not return version '$EXPECTED_VERSION', got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] \
|
||||||
|
|| die "success path did not exit with code 0, got $EXIT_CODE"
|
||||||
|
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
26
test/installation/nvm_get_latest/nvm_get_latest failed redirect
Executable file
26
test/installation/nvm_get_latest/nvm_get_latest failed redirect
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
unset -f curl wget
|
||||||
|
}
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
curl() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
wget() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT="$(nvm_get_latest 2>&1)"
|
||||||
|
EXIT_CODE="$(nvm_get_latest >/dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_http://latest.nvm.sh did not redirect to the latest release on Github" ] \
|
||||||
|
|| die "failed redirect did not report correct error message, got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_2" ] \
|
||||||
|
|| die "failed redirect did not exit with code 2, got $EXIT_CODE"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
nvm deactivate
|
||||||
nvm uninstall v0.10.7
|
nvm uninstall v0.10.7
|
||||||
|
|
||||||
if [ -f ".nvmrc" ]; then
|
if [ -f ".nvmrc" ]; then
|
||||||
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"
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
13
test/slow/nvm exec/teardown_dir
Executable file
13
test/slow/nvm exec/teardown_dir
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm deactivate
|
||||||
|
nvm uninstall v0.10.7
|
||||||
|
nvm uninstall v0.11.7
|
||||||
|
|
||||||
|
rm .nvmrc
|
||||||
|
|
||||||
|
if [ -f ".nvmrc.bak" ]; then
|
||||||
|
mv .nvmrc.bak .nvmrc
|
||||||
|
fi
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
. ../../../nvm.sh
|
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
|
||||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
|
||||||
|
|
||||||
# Install from binary
|
|
||||||
nvm install $NVM_TEST_VERSION
|
|
||||||
|
|
||||||
# Check
|
|
||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
. ../../../nvm.sh
|
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
|
||||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
|
||||||
|
|
||||||
# Install from source
|
|
||||||
nvm install -s $NVM_TEST_VERSION
|
|
||||||
|
|
||||||
# Check
|
|
||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
|
||||||
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
. ../../../nvm.sh
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# Check
|
|
||||||
[ -d ../../../v0.9.7 ]
|
|
||||||
[ -d ../../../v0.9.12 ]
|
|
||||||
|
|
||||||
# Use the first one
|
|
||||||
nvm use 0.9.7
|
|
||||||
|
|
||||||
# Use the latest one
|
|
||||||
nvm use 0.9
|
|
||||||
node --version | grep v0.9.12
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
. ../../../nvm.sh
|
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
|
||||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
|
||||||
|
|
||||||
# Install from binary
|
|
||||||
cat "$NVM_TEST_VERSION" > .nvmrc
|
|
||||||
|
|
||||||
nvm install
|
|
||||||
|
|
||||||
# Check
|
|
||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
. ../../../nvm.sh
|
|
||||||
|
|
||||||
NVM_TEST_VERSION=v0.10.7
|
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
|
||||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
|
||||||
|
|
||||||
# Install from binary
|
|
||||||
cat "$NVM_TEST_VERSION" > .nvmrc
|
|
||||||
|
|
||||||
nvm install -s
|
|
||||||
|
|
||||||
# Check
|
|
||||||
[ -d ../../../$NVM_TEST_VERSION ]
|
|
||||||
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm use 0.10.28 > /dev/null
|
||||||
|
|
||||||
|
EXPECTED_MSG="Can not reinstall packages from the current version of node."
|
||||||
|
ACTUAL_MSG="$(nvm reinstall-packages 0.10.28 2>&1 > /dev/null)"
|
||||||
|
[ "~$ACTUAL_MSG" = "~$EXPECTED_MSG" ] || die "'nvm use 0.10.28 && nvm reinstall-packages 0.10.28' did not fail with the right message: '$ACTUAL_MESSAGE'"
|
||||||
|
|
||||||
|
EXPECTED_ERROR_CODE="2"
|
||||||
|
ACTUAL_ERROR_CODE="$(nvm reinstall-packages 0.10.28 > /dev/null 2>&1 ; echo $?)"
|
||||||
|
[ "~$ACTUAL_ERROR_CODE" = "~$EXPECTED_ERROR_CODE" ] || die "'nvm use 0.10.28 && nvm reinstall-packages 0.10.28' did not fail with the right error code: expected '$EXPECTED_ERROR_CODE', got '$ACTUAL_ERROR_CODE'"
|
||||||
|
|
||||||
10
test/slow/nvm reinstall-packages/setup_dir
Executable file
10
test/slow/nvm reinstall-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 reinstall-packages/should work as expected
Executable file
21
test/slow/nvm reinstall-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 reinstall-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 reinstall-packages/teardown_dir
Executable file
12
test/slow/nvm reinstall-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
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
nvm deactivate
|
||||||
nvm uninstall v0.10.7
|
nvm uninstall v0.10.7
|
||||||
|
|
||||||
rm .nvmrc
|
rm .nvmrc
|
||||||
|
|||||||
17
test/sourcing/Sourcing nvm.sh should use the default if available
Executable file
17
test/sourcing/Sourcing nvm.sh should use the default if available
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
echo '0.10.1' > ../../alias/default || die 'creation of default alias failed'
|
||||||
|
|
||||||
|
. ../../nvm.sh || die 'sourcing returned nonzero exit code'
|
||||||
|
|
||||||
|
NVM_LS_CURRENT="$(nvm ls current | \grep -o v0.10.1)"
|
||||||
|
[ "_$NVM_LS_CURRENT" = '_v0.10.1' ] || die "'nvm ls current' did not return '-> v0.10.1', got '$NVM_LS_CURRENT'"
|
||||||
|
|
||||||
|
# NVM_LS_CURRENT_COLORED="$(nvm ls current | sed -n l)"
|
||||||
|
|
||||||
|
NVM_ALIAS_DEFAULT="$(nvm alias default)"
|
||||||
|
[ "_$NVM_ALIAS_DEFAULT" = "_default -> 0.10.1 (-> v0.10.1)" ] \
|
||||||
|
|| die "'nvm alias default did not return 'default -> 0.10.1 (-> v0.10.1)', got '$NVM_ALIAS_DEFAULT'"
|
||||||
|
|
||||||
28
test/sourcing/Sourcing nvm.sh with --install and .nvmrc should install it
Executable file
28
test/sourcing/Sourcing nvm.sh with --install and .nvmrc should install it
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
supports_source_options () {
|
||||||
|
[ "_$(echo 'echo $1' | . /dev/stdin yes)" = "_yes" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! supports_source_options; then
|
||||||
|
echo 'this shell does not support passing options on sourcing'
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo '0.10.2' > ../../.nvmrc || die 'creation of .nvmrc failed'
|
||||||
|
|
||||||
|
. ../../nvm.sh --install
|
||||||
|
EXIT_CODE="$(echo $?)"
|
||||||
|
|
||||||
|
echo 'sourcing complete.'
|
||||||
|
|
||||||
|
nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: $(nvm ls)"
|
||||||
|
|
||||||
|
[ "_$(nvm_rc_version | \grep -o -e 'with version .*$')" = "_with version <0.10.2>" ] || die "nvm_rc_version $(nvm_rc_version)"
|
||||||
|
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "sourcing returned nonzero exit code: $EXIT_CODE"
|
||||||
|
|
||||||
|
NVM_LS_CURRENT="$(nvm ls current | \grep -o v0.10.2)"
|
||||||
|
[ "_$NVM_LS_CURRENT" = '_v0.10.2' ] || die "'nvm ls current' did not return '-> v0.10.2', got '$NVM_LS_CURRENT' `nvm ls`"
|
||||||
|
|
||||||
32
test/sourcing/Sourcing nvm.sh with --install should install the default
Executable file
32
test/sourcing/Sourcing nvm.sh with --install should install the default
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
supports_source_options () {
|
||||||
|
[ "_$(echo 'echo $1' | . /dev/stdin yes)" = "_yes" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! supports_source_options; then
|
||||||
|
echo 'this shell does not support passing options on sourcing'
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo '0.10.2' > ../../alias/default || die 'creation of default alias failed'
|
||||||
|
|
||||||
|
echo 'sourcing nvm with --install...'
|
||||||
|
|
||||||
|
. ../../nvm.sh --install
|
||||||
|
EXIT_CODE="$(echo $?)"
|
||||||
|
|
||||||
|
echo 'sourcing complete.'
|
||||||
|
|
||||||
|
nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: $(nvm ls)"
|
||||||
|
|
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "sourcing returned nonzero exit code: $EXIT_CODE"
|
||||||
|
|
||||||
|
NVM_LS_CURRENT="$(nvm ls current | \grep -o v0.10.2)"
|
||||||
|
[ "_$NVM_LS_CURRENT" = '_v0.10.2' ] || die "'nvm ls current' did not return '-> v0.10.2', got '$NVM_LS_CURRENT'"
|
||||||
|
|
||||||
|
NVM_ALIAS_DEFAULT="$(nvm alias default)"
|
||||||
|
[ "_$NVM_ALIAS_DEFAULT" = "_default -> 0.10.2 (-> v0.10.2)" ] \
|
||||||
|
|| die "'nvm alias default did not return 'default -> 0.10.2 (-> v0.10.2)', got '$NVM_ALIAS_DEFAULT'"
|
||||||
|
|
||||||
12
test/sourcing/setup
Executable file
12
test/sourcing/setup
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir -p ../../alias
|
||||||
|
rm -f ../../.nvmrc
|
||||||
|
rm -rf ../../v0.10.7
|
||||||
|
rm -rf ../../v0.9.7
|
||||||
|
rm -rf ../../v0.9.12
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm install 0.10.1 || echo >&2 'nvm install 0.10.1 failed'
|
||||||
|
nvm unload || echo >&2 'nvm unload failed'
|
||||||
|
|
||||||
7
test/sourcing/teardown
Executable file
7
test/sourcing/teardown
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
rm -rf ../../alias
|
||||||
|
rm -rf ../../v0.10.1
|
||||||
|
rm -rf ../../v0.10.2
|
||||||
|
rm -f ../../.nvmrc
|
||||||
|
|
||||||
Reference in New Issue
Block a user