commit 02f77ff8011bc56d67b477f208998f5efa29c9f8 Author: Buddy Sandidge Date: Wed Feb 3 20:44:00 2016 -0800 Squashed 'nvm/' content from commit 21c372795 git-subtree-dir: nvm git-subtree-split: 21c37279556a0576a411ca01124487784105d4b4 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..50ca329 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..852b572 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +HEAD +src +v* +alias + +# For testing +test/bak +.urchin.log +.urchin_stdout + +node_modules/ +npm-debug.log + +.DS_Store +current diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..529045f --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +src +v* +alias + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1b17b9f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +language: c # defaults to ruby +addons: + apt_packages: + - zsh + - ksh +before_install: + - curl --version + - wget --version +install: + - (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s https://registry.npmjs.com/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*) + - chmod +x /tmp/urchin/package/urchin + - '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y' +script: + - export PATH=$(echo $PATH | sed 's/::/:/') + - NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL +env: + - SHELL=bash TEST_SUITE=install_script + - SHELL=sh TEST_SUITE=fast + - SHELL=dash TEST_SUITE=fast + - SHELL=bash TEST_SUITE=fast + - SHELL=zsh TEST_SUITE=fast +# - SHELL=ksh TEST_SUITE=fast + - 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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5948d7d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +Thanks for contributing to `nvm`! + +We love pull requests, they're our favorite. + +However, before submitting, please review the following: + + - Please include tests. Changes with tests will be merged very quickly. + - Please manually confirm that your changes work in `bash`, `sh`/`dash`, `ksh`, and `zsh`. Fast tests do run in these shells, but it's nice to manually verify also. + - Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc. + - Any time you make a change to your PR, please rebase freshly on top of master. Nobody likes merge commits. + +Even if you don't have all of these items covered, please still feel free to submit a PR! Someone else may be inspired and volunteer to complete it for you. + +Thanks again! + diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..336298e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2010-2016 Tim Caswell + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dbad8d8 --- /dev/null +++ b/Makefile @@ -0,0 +1,77 @@ + # Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) + # 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=... `. +SHELLS := sh bash dash zsh # ksh (#574) + # Generate 'test-' 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=<...> `. + # Test suites are the names of subfolders of './test'. +TEST_SUITE := $(shell find ./test/* -type d -prune -exec basename {} \;) + + +# Default target (by virtue of being the first non '.'-prefixed in the file). +.PHONY: _no-target-specified +_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) + +# Lists all targets defined in this makefile. +.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 + +# Set of test- 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= release`, where 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= 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" diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..daa29b8 --- /dev/null +++ b/README.markdown @@ -0,0 +1,266 @@ +# Node Version Manager [![Build Status](https://travis-ci.org/creationix/nvm.svg?branch=master)][3] + +## 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. + +Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/nvm/issues/284)). Three alternatives exist, which are neither supported nor developed by us: + - [nvm-windows](https://github.com/coreybutler/nvm-windows) + - [nodist](https://github.com/marcelklehr/nodist) + +Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us: + - [nvm](https://github.com/derekstavis/plugin-nvm) plugin for [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish), which makes nvm and its completions available in fish shell + - [bass](https://github.com/edc/bass) allows to use utilities written for Bash in fish shell + +Note: We still have some problems with FreeBSD, because there is no pre-built binary from official for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc), see the issue ticket: + - [[#900] [Bug] nodejs on FreeBSD need to be patched ](https://github.com/creationix/nvm/issues/900) + - [nodejs/node#3716](https://github.com/nodejs/node/issues/3716) + +Note: On OSX, if you do not have XCode installed and you do not wish to download the ~4.3GB file, you can install the `Command Line Tools`. You can check out this blog post on how to just that: + - [How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode)](http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/) + +Homebrew installation is not supported. + +### Install script + +To install or update nvm, you can use the [install script][2] using cURL: + + curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash + +or Wget: + + wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash + +The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`). + +You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR`, and `PROFILE` variables. +Eg: `curl ... | NVM_DIR="path/to/nvm" bash` + +*NB. The installer can use `git`, `curl`, or `wget` to download `nvm`, whatever is available.* + +### Manual install + +For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in `~/.nvm`. + +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 && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags` + +To activate nvm, you need to source it from your shell: + + . ~/.nvm/nvm.sh + +Add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login: + + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm + +### Manual upgrade + +For manual upgrade with `git`, change to the `$NVM_DIR`, pull down the latest changes, and check out the latest version: + + cd "$NVM_DIR" && git pull origin master && git checkout `git describe --abbrev=0 --tags` + +## Usage + +You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory). +`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 v5.0.x release of node, do this: + + nvm install 5.0 + +And then in any new shell just use the installed version: + + nvm use 5.0 + +Or you can just run it: + + nvm run 5.0 --version + +Or, you can run any arbitrary command in a subshell with the desired version of node: + + nvm exec 4.2 node --version + +You can also get the path to the executable to where it was installed: + + nvm which 5.0 + +In place of a version pointer like "0.10" or "5.0" or "4.2.1", you can use the following special default aliases with `nvm install`, `nvm use`, `nvm run`, `nvm exec`, `nvm which`, etc: + + - `node`: this installs the latest version of [`node`](https://nodejs.org/en/) + - `iojs`: this installs the latest version of [`io.js`](https://iojs.org/en/) + - `stable`: this alias is deprecated, and only truly applies to `node` `v0.12` and earlier. Currently, this is an alias for `node`. + - `unstable`: this alias points to `node` `v0.11` - the last "unstable" node release, since post-1.0, all node versions are stable. (in semver, versions communicate breakage, not stability). + +If you want to install a new version of Node.js and migrate npm packages from a previous version: + + nvm install node --reinstall-packages-from=node + +This will first use "nvm version node" to identify the current version you're migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs "nvm reinstall-packages" to reinstall the npm packages from your prior version of Node to the new one. + +You can also install and migrate npm packages from specific versions of Node like this: + + nvm install v5.0 --reinstall-packages-from=4.2 + nvm install v4.2 --reinstall-packages-from=iojs + +If you want to install [io.js](https://github.com/iojs/io.js/): + + nvm install iojs + +If you want to install a new version of io.js and migrate npm packages from a previous version: + + nvm install iojs --reinstall-packages-from=iojs + +The same guidelines mentioned for migrating npm packages in Node.js are applicable to io.js. + +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: + + nvm ls + +If you want to see what versions are available to install: + + nvm ls-remote + +To restore your PATH, you can deactivate it. + + nvm deactivate + +To set a default Node version to be used in any new shell, use the alias 'default': + + nvm alias default node + +To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`: + + export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist + nvm install node + + NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 4.2 + +To use a mirror of the iojs binaries, set `$NVM_IOJS_ORG_MIRROR`: + + export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist + nvm install iojs-v1.0.3 + + NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3 + +`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 + +nvm is released under the MIT license. + + +Copyright (C) 2010-2016 Tim Caswell + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +## Running tests +Tests are written in [Urchin]. Install Urchin (and other dependencies) like so: + + npm install + +There are slow tests and fast tests. The slow tests do things like install node +and check that the right versions are used. The fast tests fake this to test +things like aliases and uninstalling. From the root of the nvm git repository, +run the fast tests like this. + + npm run test/fast + +Run the slow tests like this. + + npm run test/slow + +Run all of the tests like this + + npm test + +Nota bene: Avoid running nvm while the tests are running. + +## Bash completion + +To activate, you need to source `bash_completion`: + + [[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion + +Put the above sourcing line just below the sourcing line for NVM in your profile (`.bashrc`, `.bash_profile`). + +### Usage + +nvm + + $ nvm [tab][tab] + alias deactivate install ls run unload + clear-cache exec list ls-remote unalias use + current help list-remote reinstall-packages uninstall version + +nvm alias + + $ nvm alias [tab][tab] + default + + $ nvm alias my_alias [tab][tab] + v0.6.21 v0.8.26 v0.10.28 + +nvm use + + $ nvm use [tab][tab] + my_alias default v0.6.21 v0.8.26 v0.10.28 + +nvm uninstall + + $ nvm uninstall [tab][tab] + my_alias default v0.6.21 v0.8.26 v0.10.28 + +## Compatibility Issues +`nvm` will encounter some issues if you have some non-default settings set. (see [#606](/../../issues/606)) +The following are known to cause issues: + +Inside `~/.npmrc` +``` +prefix='some/path' +``` +Environment Variables: +``` +$NPM_CONFIG_PREFIX +$PREFIX +``` +Shell settings: +``` +set -e +``` + +## Problems + +If you try to install a node version and the installation fails, be sure to delete the node downloads from src (~/.nvm/src/) or you might get an error when trying to reinstall them again or you might get an error like the following: + + curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume. + +Where's my 'sudo node'? Check out this link: + +https://github.com/creationix/nvm/issues/43 + +On Arch Linux and other systems using python3 by default, before running *install* you need to + + export PYTHON=python2 + +After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source: + + nvm install -s 0.8.6 + +If setting the `default` alias does not establish the node version in new shells (i.e. `nvm current` yields `system`), ensure that the system's node PATH is set before the `nvm.sh` source line in your shell profile (see [#658](https://github.com/creationix/nvm/issues/658)) + +[1]: https://github.com/creationix/nvm.git +[2]: https://github.com/creationix/nvm/blob/v0.30.2/install.sh +[3]: https://travis-ci.org/creationix/nvm +[Urchin]: https://github.com/scraperwiki/urchin +[Fish]: http://fishshell.com diff --git a/bash_completion b/bash_completion new file mode 100644 index 0000000..d538388 --- /dev/null +++ b/bash_completion @@ -0,0 +1,92 @@ +#!/usr/bin/env bash + +# bash completion for Node Version Manager (NVM) + +__nvm_generate_completion() +{ + declare current_word + current_word="${COMP_WORDS[COMP_CWORD]}" + COMPREPLY=($(compgen -W "$1" -- "$current_word")) + return 0 +} + +__nvm_commands () +{ + declare current_word + declare command + + current_word="${COMP_WORDS[COMP_CWORD]}" + + COMMANDS='\ + help install uninstall use run exec \ + alias unalias reinstall-packages \ + current list ls list-remote ls-remote \ + clear-cache deactivate unload \ + version which' + + if [ ${#COMP_WORDS[@]} == 4 ]; then + + command="${COMP_WORDS[COMP_CWORD-2]}" + case "${command}" in + alias) __nvm_installed_nodes ;; + esac + + else + + case "${current_word}" in + -*) __nvm_options ;; + *) __nvm_generate_completion "$COMMANDS" ;; + esac + + fi +} + +__nvm_options () +{ + OPTIONS='' + __nvm_generate_completion "$OPTIONS" +} + +__nvm_installed_nodes () +{ + __nvm_generate_completion "$(nvm_ls) $(__nvm_aliases)" +} + +__nvm_aliases () +{ + declare aliases + aliases="" + if [ -d $NVM_DIR/alias ]; then + aliases="`cd $NVM_DIR/alias && command ls`" + fi + echo "${aliases}" +} + +__nvm_alias () +{ + __nvm_generate_completion "$(__nvm_aliases)" +} + +__nvm () +{ + declare previous_word + previous_word="${COMP_WORDS[COMP_CWORD-1]}" + + case "$previous_word" in + use|run|exec|ls|list|uninstall) __nvm_installed_nodes ;; + alias|unalias) __nvm_alias ;; + *) __nvm_commands ;; + esac + + return 0 +} + +# 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 +# ZSH, load and run bashcompinit before calling the complete function. +if [[ -n ${ZSH_VERSION-} ]]; then + autoload -U +X bashcompinit && bashcompinit +fi + +complete -o default -o nospace -F __nvm nvm + diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..15824c4 --- /dev/null +++ b/install.sh @@ -0,0 +1,269 @@ +#!/bin/bash + +{ # this ensures the entire script is downloaded # + +nvm_has() { + type "$1" > /dev/null 2>&1 +} + +if [ -z "$NVM_DIR" ]; then + NVM_DIR="$HOME/.nvm" +fi + +nvm_latest_version() { + echo "v0.30.2" +} + +# +# 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 unless the method is "script-nvm-exec" +# +nvm_source() { + local NVM_METHOD + NVM_METHOD="$1" + local NVM_SOURCE_URL + NVM_SOURCE_URL="$NVM_SOURCE" + if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then + NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec" + elif [ -z "$NVM_SOURCE_URL" ]; then + if [ "_$NVM_METHOD" = "_script" ]; then + NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh" + elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then + NVM_SOURCE_URL="https://github.com/creationix/nvm.git" + else + echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD" + return 1 + fi + fi + echo "$NVM_SOURCE_URL" +} + +nvm_download() { + if nvm_has "curl"; then + curl -q $* + elif nvm_has "wget"; then + # Emulate curl with wget + ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \ + -e 's/-L //' \ + -e 's/-I /--server-response /' \ + -e 's/-s /-q /' \ + -e 's/-o /-O /' \ + -e 's/-C - /-c /') + wget $ARGS + fi +} + +install_nvm_from_git() { + if [ -d "$NVM_DIR/.git" ]; then + echo "=> nvm is already installed in $NVM_DIR, trying to update using git" + 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 + cd "$NVM_DIR" && command git checkout --quiet $(nvm_latest_version) + if [ ! -z "$(cd "$NVM_DIR" && git show-ref refs/heads/master)" ]; then + if git branch --quiet 2>/dev/null; then + cd "$NVM_DIR" && command git branch --quiet -D master >/dev/null 2>&1 + else + echo >&2 "Your version of git is out of date. Please update it!" + cd "$NVM_DIR" && command git branch -D master >/dev/null 2>&1 + fi + fi + return +} + +install_nvm_as_script() { + local NVM_SOURCE_LOCAL + NVM_SOURCE_LOCAL=$(nvm_source script) + local NVM_EXEC_SOURCE + NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec) + + # Downloading to $NVM_DIR + mkdir -p "$NVM_DIR" + if [ -f "$NVM_DIR/nvm.sh" ]; then + echo "=> nvm is already installed in $NVM_DIR, trying to update the script" + else + echo "=> Downloading nvm as script to '$NVM_DIR'" + fi + nvm_download -s "$NVM_SOURCE_LOCAL" -o "$NVM_DIR/nvm.sh" || { + echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'" + 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 + } +} + +# +# Detect profile file if not specified as environment variable +# (eg: PROFILE=~/.myprofile) +# The echo'ed path is guaranteed to be an existing file +# Otherwise, an empty string is returned +# +nvm_detect_profile() { + if [ -n "$PROFILE" -a -f "$PROFILE" ]; then + echo "$PROFILE" + return + fi + + local DETECTED_PROFILE + DETECTED_PROFILE='' + local SHELLTYPE + SHELLTYPE="$(basename /$SHELL)" + + if [ $SHELLTYPE = "bash" ]; then + if [ -f "$HOME/.bashrc" ]; then + DETECTED_PROFILE="$HOME/.bashrc" + elif [ -f "$HOME/.bash_profile" ]; then + DETECTED_PROFILE="$HOME/.bash_profile" + fi + elif [ $SHELLTYPE = "zsh" ]; then + DETECTED_PROFILE="$HOME/.zshrc" + fi + + if [ -z "$DETECTED_PROFILE" ]; then + if [ -f "$HOME/.profile" ]; then + DETECTED_PROFILE="$HOME/.profile" + elif [ -f "$HOME/.bashrc" ]; then + DETECTED_PROFILE="$HOME/.bashrc" + elif [ -f "$HOME/.bash_profile" ]; then + DETECTED_PROFILE="$HOME/.bash_profile" + elif [ -f "$HOME/.zshrc" ]; then + DETECTED_PROFILE="$HOME/.zshrc" + fi + fi + + if [ ! -z "$DETECTED_PROFILE" ]; then + echo "$DETECTED_PROFILE" + fi +} + +# +# Check whether the user has any globally-installed npm modules in their system +# Node, and warn them if so. +# +nvm_check_global_modules() { + command -v npm >/dev/null 2>&1 || return 0 + + local NPM_VERSION + NPM_VERSION="$(npm --version)" + NPM_VERSION="${NPM_VERSION:--1}" + [ "${NPM_VERSION%%[!-0-9]*}" -gt 0 ] || return 0 + + local NPM_GLOBAL_MODULES + NPM_GLOBAL_MODULES="$( + npm list -g --depth=0 | + sed '/ npm@/d' | + sed '/ (empty)$/d' + )" + + local MODULE_COUNT + MODULE_COUNT="$( + printf %s\\n "$NPM_GLOBAL_MODULES" | + sed -ne '1!p' | # Remove the first line + wc -l | tr -d ' ' # Count entries + )" + + if [ $MODULE_COUNT -ne 0 ]; then + cat <<-'END_MESSAGE' + => You currently have modules installed globally with `npm`. These will no + => longer be linked to the active version of Node when you install a new node + => with `nvm`; and they may (depending on how you construct your `$PATH`) + => override the binaries of modules installed with `nvm`: + + END_MESSAGE + printf %s\\n "$NPM_GLOBAL_MODULES" + cat <<-'END_MESSAGE' + + => If you wish to uninstall them at a later point (or re-install them under your + => `nvm` Nodes), you can remove them from the system Node as follows: + + $ nvm use system + $ npm uninstall -g a_module + + END_MESSAGE + fi +} + +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" + exit 1 + fi + install_nvm_from_git + elif [ "~$METHOD" = "~script" ]; then + if ! nvm_has "nvm_download"; then + echo >&2 "You need curl or wget to install nvm" + exit 1 + fi + install_nvm_as_script + fi + + echo + + local NVM_PROFILE + NVM_PROFILE=$(nvm_detect_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 + if ! command 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 + + nvm_check_global_modules + + 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_reset nvm_has nvm_latest_version \ + nvm_source nvm_download install_nvm_as_script install_nvm_from_git \ + nvm_detect_profile nvm_check_global_modules nvm_do_install +} + +[ "_$NVM_ENV" = "_testing" ] || nvm_do_install + +} # this ensures the entire script is downloaded # diff --git a/nvm-exec b/nvm-exec new file mode 100755 index 0000000..57067af --- /dev/null +++ b/nvm-exec @@ -0,0 +1,13 @@ +#!/bin/bash + +DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +. "$DIR/nvm.sh" --no-use + +if [ -n "$NODE_VERSION" ]; then + nvm use $NODE_VERSION > /dev/null || (echo "NODE_VERSION not set" >&2 && exit 127) +else + nvm use > /dev/null || (echo "No .nvmrc file found" >&2 && exit 127) +fi + +exec "$@" diff --git a/nvm.sh b/nvm.sh new file mode 100755 index 0000000..d4250dd --- /dev/null +++ b/nvm.sh @@ -0,0 +1,2383 @@ +# Node Version Manager +# Implemented as a POSIX-compliant function +# Should work on sh, dash, bash, ksh, zsh +# To use source this file from your bash profile +# +# Implemented by Tim Caswell +# with much bash help from Matthew Ranney + +{ # this ensures the entire script is downloaded # + +NVM_SCRIPT_SOURCE="$_" + +nvm_has() { + type "$1" > /dev/null 2>&1 +} + +nvm_is_alias() { + # this is intentionally not "command alias" so it works in zsh. + \alias "$1" > /dev/null 2>&1 +} + +nvm_get_latest() { + local NVM_LATEST_URL + if nvm_has "curl"; then + NVM_LATEST_URL="$(curl -q -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)" + elif nvm_has "wget"; then + NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')" + else + >&2 echo 'nvm needs curl or wget to proceed.' + return 1 + fi + if [ "_$NVM_LATEST_URL" = "_" ]; then + >&2 echo "http://latest.nvm.sh did not redirect to the latest release on Github" + return 2 + else + echo "$NVM_LATEST_URL" | command awk -F '/' '{print $NF}' + fi +} + +nvm_download() { + if nvm_has "curl"; then + curl -q $* + elif nvm_has "wget"; then + # Emulate curl with wget + ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \ + -e 's/-L //' \ + -e 's/-I /--server-response /' \ + -e 's/-s /-q /' \ + -e 's/-o /-O /' \ + -e 's/-C - /-c /') + eval wget $ARGS + fi +} + +nvm_has_system_node() { + [ "$(nvm deactivate >/dev/null 2>&1 && command -v node)" != '' ] +} + +nvm_has_system_iojs() { + [ "$(nvm deactivate >/dev/null 2>&1 && command -v iojs)" != '' ] +} + +nvm_print_npm_version() { + if nvm_has "npm"; then + echo " (npm v$(npm --version 2>/dev/null))" + fi +} + +# Make zsh glob matching behave same as bash +# This fixes the "zsh: no matches found" errors +if [ -z "${NVM_CD_FLAGS-}" ]; then + export NVM_CD_FLAGS='' +fi +if nvm_has "unsetopt"; then + unsetopt nomatch 2>/dev/null + NVM_CD_FLAGS="-q" +fi + +# Auto detect the NVM_DIR when not set +if [ -z "${NVM_DIR-}" ]; then + if [ -n "$BASH_SOURCE" ]; then + NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}" + fi + NVM_DIR="$(cd $NVM_CD_FLAGS "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" > /dev/null && \pwd)" + export NVM_DIR +fi +unset NVM_SCRIPT_SOURCE 2> /dev/null + + +# Setup mirror location if not already set +if [ -z "${NVM_NODEJS_ORG_MIRROR-}" ]; then + export NVM_NODEJS_ORG_MIRROR="https://nodejs.org/dist" +fi + +if [ -z "$NVM_IOJS_ORG_MIRROR" ]; then + export NVM_IOJS_ORG_MIRROR="https://iojs.org/dist" +fi + +nvm_tree_contains_path() { + local tree + tree="$1" + local node_path + node_path="$2" + + if [ "@$tree@" = "@@" ] || [ "@$node_path@" = "@@" ]; then + >&2 echo "both the tree and the node path are required" + return 2 + fi + + local pathdir + pathdir=$(dirname "$node_path") + while [ "$pathdir" != "" ] && [ "$pathdir" != "." ] && [ "$pathdir" != "/" ] && [ "$pathdir" != "$tree" ]; do + pathdir=$(dirname "$pathdir") + done + [ "$pathdir" = "$tree" ] +} + +# Traverse up in directory tree to find containing folder +nvm_find_up() { + local path + path=$PWD + while [ "$path" != "" ] && [ ! -f "$path/$1" ]; do + path=${path%/*} + done + echo "$path" +} + + +nvm_find_nvmrc() { + local dir + dir="$(nvm_find_up '.nvmrc')" + if [ -e "$dir/.nvmrc" ]; then + echo "$dir/.nvmrc" + fi +} + +# Obtain nvm version from rc file +nvm_rc_version() { + export NVM_RC_VERSION='' + local NVMRC_PATH + NVMRC_PATH="$(nvm_find_nvmrc)" + if [ -e "$NVMRC_PATH" ]; then + read -r NVM_RC_VERSION < "$NVMRC_PATH" + echo "Found '$NVMRC_PATH' with version <$NVM_RC_VERSION>" + else + >&2 echo "No .nvmrc file found" + return 1 + fi +} + +nvm_version_greater() { + local LHS + LHS="$(nvm_normalize_version "$1")" + local RHS + RHS="$(nvm_normalize_version "$2")" + [ "$LHS" -gt "$RHS" ]; +} + +nvm_version_greater_than_or_equal_to() { + local LHS + LHS="$(nvm_normalize_version "$1")" + local RHS + RHS="$(nvm_normalize_version "$2")" + [ "$LHS" -ge "$RHS" ]; +} + +nvm_version_dir() { + local NVM_WHICH_DIR + NVM_WHICH_DIR="$1" + if [ -z "$NVM_WHICH_DIR" ] || [ "_$NVM_WHICH_DIR" = "_new" ]; then + echo "$NVM_DIR/versions/node" + elif [ "_$NVM_WHICH_DIR" = "_iojs" ]; then + echo "$NVM_DIR/versions/io.js" + elif [ "_$NVM_WHICH_DIR" = "_old" ]; then + echo "$NVM_DIR" + else + echo "unknown version dir" >&2 + return 3 + fi +} + +nvm_alias_path() { + echo "$(nvm_version_dir old)/alias" +} + +nvm_version_path() { + local VERSION + VERSION="$1" + if [ -z "$VERSION" ]; then + echo "version is required" >&2 + return 3 + elif nvm_is_iojs_version "$VERSION"; then + echo "$(nvm_version_dir iojs)/$(nvm_strip_iojs_prefix "$VERSION")" + elif nvm_version_greater 0.12.0 "$VERSION"; then + echo "$(nvm_version_dir old)/$VERSION" + else + echo "$(nvm_version_dir new)/$VERSION" + fi +} + +nvm_ensure_version_installed() { + local PROVIDED_VERSION + PROVIDED_VERSION="$1" + local LOCAL_VERSION + local EXIT_CODE + LOCAL_VERSION="$(nvm_version "$PROVIDED_VERSION")" + EXIT_CODE="$?" + local NVM_VERSION_DIR + if [ "_$EXIT_CODE" = "_0" ]; then + NVM_VERSION_DIR="$(nvm_version_path "$LOCAL_VERSION")" + fi + if [ "_$EXIT_CODE" != "_0" ] || [ ! -d "$NVM_VERSION_DIR" ]; then + VERSION="$(nvm_resolve_alias "$PROVIDED_VERSION")" + if [ $? -eq 0 ]; then + echo "N/A: version \"$PROVIDED_VERSION -> $VERSION\" is not yet installed" >&2 + else + local PREFIXED_VERSION + PREFIXED_VERSION="$(nvm_ensure_version_prefix "$PROVIDED_VERSION")" + echo "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed" >&2 + fi + return 1 + fi +} + +# Expand a version using the version cache +nvm_version() { + local PATTERN + PATTERN="$1" + local VERSION + # The default version is the current one + if [ -z "$PATTERN" ]; then + PATTERN='current' + fi + + if [ "$PATTERN" = "current" ]; then + nvm_ls_current + return $? + fi + + local NVM_NODE_PREFIX + NVM_NODE_PREFIX="$(nvm_node_prefix)" + case "_$PATTERN" in + "_$NVM_NODE_PREFIX" | "_$NVM_NODE_PREFIX-") + PATTERN="stable" + ;; + esac + VERSION="$(nvm_ls "$PATTERN" | command tail -n1)" + if [ -z "$VERSION" ] || [ "_$VERSION" = "_N/A" ]; then + echo "N/A" + return 3; + else + echo "$VERSION" + fi +} + +nvm_remote_version() { + local PATTERN + PATTERN="$1" + local VERSION + if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then + case "_$PATTERN" in + "_$(nvm_iojs_prefix)") + VERSION="$(nvm_ls_remote_iojs | command tail -n1)" + ;; + *) + VERSION="$(nvm_ls_remote "$PATTERN")" + ;; + esac + else + VERSION="$(nvm_remote_versions "$PATTERN" | command tail -n1)" + fi + echo "$VERSION" + if [ "_$VERSION" = '_N/A' ]; then + return 3 + fi +} + +nvm_remote_versions() { + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + local PATTERN + PATTERN="$1" + case "_$PATTERN" in + "_$NVM_IOJS_PREFIX" | "_io.js") + VERSIONS="$(nvm_ls_remote_iojs)" + ;; + "_$(nvm_node_prefix)") + VERSIONS="$(nvm_ls_remote)" + ;; + *) + if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then + echo >&2 "Implicit aliases are not supported in nvm_remote_versions." + return 1 + fi + VERSIONS="$(echo "$(nvm_ls_remote "$PATTERN") +$(nvm_ls_remote_iojs "$PATTERN")" | command grep -v "N/A" | command sed '/^$/d')" + ;; + esac + + if [ -z "$VERSIONS" ]; then + echo "N/A" + return 3 + else + echo "$VERSIONS" + fi +} + +nvm_is_valid_version() { + if nvm_validate_implicit_alias "$1" 2> /dev/null; then + return 0 + fi + case "$1" in + "$(nvm_iojs_prefix)" | \ + "$(nvm_node_prefix)") + return 0 + ;; + *) + local VERSION + VERSION="$(nvm_strip_iojs_prefix "$1")" + nvm_version_greater "$VERSION" + ;; + esac +} + +nvm_normalize_version() { + echo "${1#v}" | command awk -F. '{ printf("%d%06d%06d\n", $1,$2,$3); }' +} + +nvm_ensure_version_prefix() { + local NVM_VERSION + NVM_VERSION="$(nvm_strip_iojs_prefix "$1" | command sed -e 's/^\([0-9]\)/v\1/g')" + if nvm_is_iojs_version "$1"; then + nvm_add_iojs_prefix "$NVM_VERSION" + else + echo "$NVM_VERSION" + fi +} + +nvm_format_version() { + local VERSION + VERSION="$(nvm_ensure_version_prefix "$1")" + if [ "_$(nvm_num_version_groups "$VERSION")" != "_3" ]; then + nvm_format_version "${VERSION%.}.0" + else + echo "$VERSION" + fi +} + +nvm_num_version_groups() { + local VERSION + VERSION="$1" + VERSION="${VERSION#v}" + VERSION="${VERSION%.}" + if [ -z "$VERSION" ]; then + echo "0" + return + fi + local NVM_NUM_DOTS + NVM_NUM_DOTS=$(echo "$VERSION" | command sed -e 's/[^\.]//g') + local NVM_NUM_GROUPS + NVM_NUM_GROUPS=".$NVM_NUM_DOTS" # add extra dot, since it's (n - 1) dots at this point + echo "${#NVM_NUM_GROUPS}" +} + +nvm_strip_path() { + echo "$1" | command sed \ + -e "s#$NVM_DIR/[^/]*$2[^:]*:##g" \ + -e "s#:$NVM_DIR/[^/]*$2[^:]*##g" \ + -e "s#$NVM_DIR/[^/]*$2[^:]*##g" \ + -e "s#$NVM_DIR/versions/[^/]*/[^/]*$2[^:]*:##g" \ + -e "s#:$NVM_DIR/versions/[^/]*/[^/]*$2[^:]*##g" \ + -e "s#$NVM_DIR/versions/[^/]*/[^/]*$2[^:]*##g" +} + +nvm_prepend_path() { + if [ -z "$1" ]; then + echo "$2" + else + echo "$2:$1" + fi +} + +nvm_binary_available() { + # binaries started with node 0.8.6 + local FIRST_VERSION_WITH_BINARY + FIRST_VERSION_WITH_BINARY="0.8.6" + nvm_version_greater_than_or_equal_to "$(nvm_strip_iojs_prefix "$1")" "$FIRST_VERSION_WITH_BINARY" +} + +nvm_alias() { + local ALIAS + ALIAS="$1" + if [ -z "$ALIAS" ]; then + echo >&2 'An alias is required.' + return 1 + fi + + local NVM_ALIAS_PATH + NVM_ALIAS_PATH="$(nvm_alias_path)/$ALIAS" + if [ ! -f "$NVM_ALIAS_PATH" ]; then + echo >&2 'Alias does not exist.' + return 2 + fi + + command cat "$NVM_ALIAS_PATH" +} + +nvm_ls_current() { + local NVM_LS_CURRENT_NODE_PATH + NVM_LS_CURRENT_NODE_PATH="$(command which node 2> /dev/null)" + if [ $? -ne 0 ]; then + echo 'none' + elif nvm_tree_contains_path "$(nvm_version_dir iojs)" "$NVM_LS_CURRENT_NODE_PATH"; then + nvm_add_iojs_prefix "$(iojs --version 2>/dev/null)" + elif nvm_tree_contains_path "$NVM_DIR" "$NVM_LS_CURRENT_NODE_PATH"; then + local VERSION + VERSION="$(node --version 2>/dev/null)" + if [ "$VERSION" = "v0.6.21-pre" ]; then + echo "v0.6.21" + else + echo "$VERSION" + fi + else + echo 'system' + fi +} + +nvm_resolve_alias() { + if [ -z "$1" ]; then + return 1 + fi + + local PATTERN + PATTERN="$1" + + local ALIAS + ALIAS="$PATTERN" + local ALIAS_TEMP + + local SEEN_ALIASES + SEEN_ALIASES="$ALIAS" + while true; do + ALIAS_TEMP="$(nvm_alias "$ALIAS" 2> /dev/null)" + + if [ -z "$ALIAS_TEMP" ]; then + break + fi + + if [ -n "$ALIAS_TEMP" ] \ + && command printf "$SEEN_ALIASES" | command grep -e "^$ALIAS_TEMP$" > /dev/null; then + ALIAS="∞" + break + fi + + SEEN_ALIASES="$SEEN_ALIASES\n$ALIAS_TEMP" + ALIAS="$ALIAS_TEMP" + done + + if [ -n "$ALIAS" ] && [ "_$ALIAS" != "_$PATTERN" ]; then + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + local NVM_NODE_PREFIX + NVM_NODE_PREFIX="$(nvm_node_prefix)" + case "_$ALIAS" in + "_∞" | \ + "_$NVM_IOJS_PREFIX" | "_$NVM_IOJS_PREFIX-" | \ + "_$NVM_NODE_PREFIX" ) + echo "$ALIAS" + ;; + *) + nvm_ensure_version_prefix "$ALIAS" + ;; + esac + return 0 + fi + + if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then + local IMPLICIT + IMPLICIT="$(nvm_print_implicit_alias local "$PATTERN" 2> /dev/null)" + if [ -n "$IMPLICIT" ]; then + nvm_ensure_version_prefix "$IMPLICIT" + fi + fi + + return 2 +} + +nvm_resolve_local_alias() { + if [ -z "$1" ]; then + return 1 + fi + + local VERSION + local EXIT_CODE + VERSION="$(nvm_resolve_alias "$1")" + EXIT_CODE=$? + if [ -z "$VERSION" ]; then + return $EXIT_CODE + fi + if [ "_$VERSION" != "_∞" ]; then + nvm_version "$VERSION" + else + echo "$VERSION" + fi +} + +nvm_iojs_prefix() { + echo "iojs" +} +nvm_node_prefix() { + echo "node" +} + +nvm_is_iojs_version() { + case "$1" in iojs-*) return 0 ;; esac + return 1 +} + +nvm_add_iojs_prefix() { + command echo "$(nvm_iojs_prefix)-$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "$1")")" +} + +nvm_strip_iojs_prefix() { + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + if [ "_$1" = "_$NVM_IOJS_PREFIX" ]; then + echo + else + echo "${1#"$NVM_IOJS_PREFIX"-}" + fi +} + +nvm_ls() { + local PATTERN + PATTERN="${1-}" + local VERSIONS + VERSIONS='' + if [ "$PATTERN" = 'current' ]; then + nvm_ls_current + return + fi + + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + local NVM_NODE_PREFIX + NVM_NODE_PREFIX="$(nvm_node_prefix)" + local NVM_VERSION_DIR_IOJS + NVM_VERSION_DIR_IOJS="$(nvm_version_dir "$NVM_IOJS_PREFIX")" + local NVM_VERSION_DIR_NEW + NVM_VERSION_DIR_NEW="$(nvm_version_dir new)" + local NVM_VERSION_DIR_OLD + NVM_VERSION_DIR_OLD="$(nvm_version_dir old)" + + case "$PATTERN" in + "$NVM_IOJS_PREFIX" | "$NVM_NODE_PREFIX" ) + PATTERN="$PATTERN-" + ;; + *) + if nvm_resolve_local_alias "$PATTERN"; then + return + fi + PATTERN="$(nvm_ensure_version_prefix "$PATTERN")" + ;; + esac + if [ "_$PATTERN" = "_N/A" ]; then + return + fi + # If it looks like an explicit version, don't do anything funny + local NVM_PATTERN_STARTS_WITH_V + case $PATTERN in + v*) NVM_PATTERN_STARTS_WITH_V=true ;; + *) NVM_PATTERN_STARTS_WITH_V=false ;; + esac + if [ $NVM_PATTERN_STARTS_WITH_V = true ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then + if [ -d "$(nvm_version_path "$PATTERN")" ]; then + VERSIONS="$PATTERN" + elif [ -d "$(nvm_version_path "$(nvm_add_iojs_prefix "$PATTERN")")" ]; then + VERSIONS="$(nvm_add_iojs_prefix "$PATTERN")" + fi + else + case "$PATTERN" in + "$NVM_IOJS_PREFIX-" | "$NVM_NODE_PREFIX-" | "system") ;; + *) + local NUM_VERSION_GROUPS + NUM_VERSION_GROUPS="$(nvm_num_version_groups "$PATTERN")" + if [ "_$NUM_VERSION_GROUPS" = "_2" ] || [ "_$NUM_VERSION_GROUPS" = "_1" ]; then + PATTERN="${PATTERN%.}." + fi + ;; + esac + + local ZHS_HAS_SHWORDSPLIT_UNSET + ZHS_HAS_SHWORDSPLIT_UNSET=1 + if nvm_has "setopt"; then + ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?) + setopt shwordsplit + fi + + local NVM_DIRS_TO_SEARCH1 + NVM_DIRS_TO_SEARCH1='' + local NVM_DIRS_TO_SEARCH2 + NVM_DIRS_TO_SEARCH2='' + local NVM_DIRS_TO_SEARCH3 + NVM_DIRS_TO_SEARCH3='' + local NVM_ADD_SYSTEM + NVM_ADD_SYSTEM=false + if nvm_is_iojs_version "$PATTERN"; then + NVM_DIRS_TO_SEARCH1="$NVM_VERSION_DIR_IOJS" + PATTERN="$(nvm_strip_iojs_prefix "$PATTERN")" + if nvm_has_system_iojs; then + NVM_ADD_SYSTEM=true + fi + elif [ "_$PATTERN" = "_$NVM_NODE_PREFIX-" ]; then + NVM_DIRS_TO_SEARCH1="$NVM_VERSION_DIR_OLD" + NVM_DIRS_TO_SEARCH2="$NVM_VERSION_DIR_NEW" + PATTERN='' + if nvm_has_system_node; then + NVM_ADD_SYSTEM=true + fi + else + NVM_DIRS_TO_SEARCH1="$NVM_VERSION_DIR_OLD" + NVM_DIRS_TO_SEARCH2="$NVM_VERSION_DIR_NEW" + NVM_DIRS_TO_SEARCH3="$NVM_VERSION_DIR_IOJS" + if nvm_has_system_iojs || nvm_has_system_node; then + NVM_ADD_SYSTEM=true + fi + fi + + if ! [ -d "$NVM_DIRS_TO_SEARCH1" ]; then + NVM_DIRS_TO_SEARCH1='' + fi + if ! [ -d "$NVM_DIRS_TO_SEARCH2" ]; then + NVM_DIRS_TO_SEARCH2="$NVM_DIRS_TO_SEARCH1" + fi + if ! [ -d "$NVM_DIRS_TO_SEARCH3" ]; then + NVM_DIRS_TO_SEARCH3="$NVM_DIRS_TO_SEARCH2" + fi + + if [ -z "$PATTERN" ]; then + PATTERN='v' + fi + if [ -n "$NVM_DIRS_TO_SEARCH1$NVM_DIRS_TO_SEARCH2$NVM_DIRS_TO_SEARCH3" ]; then + VERSIONS="$(command find "$NVM_DIRS_TO_SEARCH1" "$NVM_DIRS_TO_SEARCH2" "$NVM_DIRS_TO_SEARCH3" -maxdepth 1 -type d -name "$PATTERN*" \ + | command sed " + s#$NVM_VERSION_DIR_IOJS/#$NVM_IOJS_PREFIX-#; + \#$NVM_VERSION_DIR_IOJS# d; + s#^$NVM_DIR/##; + \#^versions\$# d; + s#^versions/##; + s#^v#$NVM_NODE_PREFIX-v#; + s#^\($NVM_IOJS_PREFIX\)[-/]v#\1.v#; + s#^\($NVM_NODE_PREFIX\)[-/]v#\1.v#" \ + | command sort -t. -u -k 2.2,2n -k 3,3n -k 4,4n \ + | command sed " + s/^\($NVM_IOJS_PREFIX\)\./\1-/; + s/^$NVM_NODE_PREFIX\.//" \ + )" + fi + + if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then + unsetopt shwordsplit + fi + fi + + if [ "${NVM_ADD_SYSTEM-}" = true ]; then + if [ -z "$PATTERN" ] || [ "_$PATTERN" = "_v" ]; then + VERSIONS="$VERSIONS$(command printf '\n%s' 'system')" + elif [ "$PATTERN" = 'system' ]; then + VERSIONS="$(command printf '%s' 'system')" + fi + fi + + if [ -z "$VERSIONS" ]; then + echo "N/A" + return 3 + fi + + echo "$VERSIONS" +} + +nvm_ls_remote() { + local PATTERN + PATTERN="$1" + if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then + PATTERN="$(nvm_ls_remote "$(nvm_print_implicit_alias remote "$PATTERN")" | command tail -n1)" + elif [ -n "$PATTERN" ]; then + PATTERN="$(nvm_ensure_version_prefix "$PATTERN")" + else + PATTERN=".*" + fi + nvm_ls_remote_index_tab node std "$NVM_NODEJS_ORG_MIRROR" "$PATTERN" +} + +nvm_ls_remote_iojs() { + nvm_ls_remote_index_tab iojs std "$NVM_IOJS_ORG_MIRROR" "$1" +} + +nvm_ls_remote_index_tab() { + if [ "$#" -lt 4 ]; then + echo "not enough arguments" >&2 + return 5 + fi + local TYPE + TYPE="$1" + local PREFIX + PREFIX='' + case "$TYPE-$2" in + iojs-std) PREFIX="$(nvm_iojs_prefix)-" ;; + node-std) PREFIX='' ;; + iojs-*) + echo "unknown type of io.js release" >&2 + return 4 + ;; + node-*) + echo "unknown type of node.js release" >&2 + return 4 + ;; + esac + local SORT_COMMAND + SORT_COMMAND='sort' + case "$TYPE" in + node) SORT_COMMAND='sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n' ;; + esac + local MIRROR + MIRROR="$3" + local PATTERN + PATTERN="$4" + local VERSIONS + if [ -n "$PATTERN" ]; then + if [ "_$TYPE" = "_iojs" ]; then + PATTERN="$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "$PATTERN")")" + else + PATTERN="$(nvm_ensure_version_prefix "$PATTERN")" + fi + else + PATTERN=".*" + fi + ZHS_HAS_SHWORDSPLIT_UNSET=1 + if nvm_has "setopt"; then + ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?) + setopt shwordsplit + fi + VERSIONS="$(nvm_download -L -s "$MIRROR/index.tab" -o - \ + | command sed " + 1d; + s/^/$PREFIX/; + s/[[:blank:]].*//" \ + | command grep -w "$PATTERN" \ + | $SORT_COMMAND)" + if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then + unsetopt shwordsplit + fi + if [ -z "$VERSIONS" ]; then + echo "N/A" + return 3 + fi + echo "$VERSIONS" +} + +nvm_checksum() { + local NVM_CHECKSUM + if nvm_has "sha1sum" && ! nvm_is_alias "sha1sum"; then + NVM_CHECKSUM="$(command sha1sum "$1" | command awk '{print $1}')" + elif nvm_has "sha1" && ! nvm_is_alias "sha1"; then + NVM_CHECKSUM="$(command sha1 -q "$1")" + elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then + NVM_CHECKSUM="$(shasum "$1" | command awk '{print $1}')" + else + echo "Unaliased sha1sum, sha1, or shasum not found." >&2 + return 2 + fi + + if [ "_$NVM_CHECKSUM" = "_$2" ]; then + return + elif [ -z "$2" ]; then + echo 'Checksums empty' #missing in raspberry pi binary + return + else + echo 'Checksums do not match.' >&2 + return 1 + fi +} + +nvm_print_versions() { + local VERSION + local FORMAT + local NVM_CURRENT + NVM_CURRENT=$(nvm_ls_current) + echo "$1" | while read -r VERSION; do + if [ "_$VERSION" = "_$NVM_CURRENT" ]; then + FORMAT='\033[0;32m-> %12s\033[0m' + elif [ "$VERSION" = "system" ]; then + FORMAT='\033[0;33m%15s\033[0m' + elif [ -d "$(nvm_version_path "$VERSION" 2> /dev/null)" ]; then + FORMAT='\033[0;34m%15s\033[0m' + else + FORMAT='%15s' + fi + command printf "$FORMAT\n" "$VERSION" + done +} + +nvm_validate_implicit_alias() { + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + local NVM_NODE_PREFIX + NVM_NODE_PREFIX="$(nvm_node_prefix)" + + case "$1" in + "stable" | "unstable" | "$NVM_IOJS_PREFIX" | "$NVM_NODE_PREFIX" ) + return + ;; + *) + echo "Only implicit aliases 'stable', 'unstable', '$NVM_IOJS_PREFIX', and '$NVM_NODE_PREFIX' are supported." >&2 + return 1 + ;; + esac +} + +nvm_print_implicit_alias() { + if [ "_$1" != "_local" ] && [ "_$1" != "_remote" ]; then + echo "nvm_print_implicit_alias must be specified with local or remote as the first argument." >&2 + return 1 + fi + + local NVM_IMPLICIT + NVM_IMPLICIT="$2" + if ! nvm_validate_implicit_alias "$NVM_IMPLICIT"; then + return 2 + fi + + local ZHS_HAS_SHWORDSPLIT_UNSET + + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + local NVM_NODE_PREFIX + NVM_NODE_PREFIX="$(nvm_node_prefix)" + local NVM_COMMAND + local NVM_ADD_PREFIX_COMMAND + local LAST_TWO + case "$NVM_IMPLICIT" in + "$NVM_IOJS_PREFIX") + NVM_COMMAND="nvm_ls_remote_iojs" + NVM_ADD_PREFIX_COMMAND="nvm_add_iojs_prefix" + if [ "_$1" = "_local" ]; then + NVM_COMMAND="nvm_ls $NVM_IMPLICIT" + fi + + ZHS_HAS_SHWORDSPLIT_UNSET=1 + if nvm_has "setopt"; then + ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?) + setopt shwordsplit + fi + + local NVM_IOJS_VERSION + local EXIT_CODE + NVM_IOJS_VERSION="$($NVM_COMMAND)" + EXIT_CODE="$?" + if [ "_$EXIT_CODE" = "_0" ]; then + NVM_IOJS_VERSION="$(echo "$NVM_IOJS_VERSION" | sed "s/^$NVM_IMPLICIT-//" | command grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq | command tail -1)" + fi + + if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then + unsetopt shwordsplit + fi + + if [ "_$NVM_IOJS_VERSION" = "_N/A" ]; then + echo "N/A" + else + $NVM_ADD_PREFIX_COMMAND "$NVM_IOJS_VERSION" + fi + return $EXIT_CODE + ;; + "$NVM_NODE_PREFIX") + echo "stable" + return + ;; + *) + NVM_COMMAND="nvm_ls_remote" + if [ "_$1" = "_local" ]; then + NVM_COMMAND="nvm_ls node" + fi + + ZHS_HAS_SHWORDSPLIT_UNSET=1 + if nvm_has "setopt"; then + ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?) + setopt shwordsplit + fi + + LAST_TWO=$($NVM_COMMAND | command grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq) + + if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then + unsetopt shwordsplit + fi + ;; + esac + local MINOR + local STABLE + local UNSTABLE + local MOD + local NORMALIZED_VERSION + + ZHS_HAS_SHWORDSPLIT_UNSET=1 + if nvm_has "setopt"; then + ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?) + setopt shwordsplit + fi + for MINOR in $LAST_TWO; do + NORMALIZED_VERSION="$(nvm_normalize_version "$MINOR")" + if [ "_0${NORMALIZED_VERSION#?}" != "_$NORMALIZED_VERSION" ]; then + STABLE="$MINOR" + else + MOD=$(expr "$NORMALIZED_VERSION" \/ 1000000 \% 2) + if [ "$MOD" -eq 0 ]; then + STABLE="$MINOR" + elif [ "$MOD" -eq 1 ]; then + UNSTABLE="$MINOR" + fi + fi + done + if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then + unsetopt shwordsplit + fi + + if [ "_$2" = '_stable' ]; then + echo "${STABLE}" + elif [ "_$2" = '_unstable' ]; then + echo "${UNSTABLE}" + fi +} + +nvm_get_os() { + local NVM_UNAME + NVM_UNAME="$(uname -a)" + local NVM_OS + case "$NVM_UNAME" in + Linux\ *) NVM_OS=linux ;; + Darwin\ *) NVM_OS=darwin ;; + SunOS\ *) NVM_OS=sunos ;; + FreeBSD\ *) NVM_OS=freebsd ;; + esac + echo "$NVM_OS" +} + +nvm_get_arch() { + local HOST_ARCH + local NVM_OS + local EXIT_CODE + + NVM_OS="$(nvm_get_os)" + # If the OS is SunOS, first try to use pkgsrc to guess + # the most appropriate arch. If it's not available, use + # isainfo to get the instruction set supported by the + # kernel. + if [ "_$NVM_OS" = "_sunos" ]; then + HOST_ARCH=$(pkg_info -Q MACHINE_ARCH pkg_install) + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + HOST_ARCH=$(isainfo -n) + fi + else + HOST_ARCH="$(uname -m)" + fi + + local NVM_ARCH + case "$HOST_ARCH" in + x86_64 | amd64) NVM_ARCH="x64" ;; + i*86) NVM_ARCH="x86" ;; + *) NVM_ARCH="$HOST_ARCH" ;; + esac + echo "$NVM_ARCH" +} + +nvm_ensure_default_set() { + local VERSION + VERSION="$1" + if [ -z "$VERSION" ]; then + echo 'nvm_ensure_default_set: a version is required' >&2 + return 1 + fi + if nvm_alias default >/dev/null 2>&1; then + # default already set + return 0 + fi + local OUTPUT + OUTPUT="$(nvm alias default "$VERSION")" + local EXIT_CODE + EXIT_CODE="$?" + echo "Creating default alias: $OUTPUT" + return $EXIT_CODE +} + +nvm_is_merged_node_version() { + nvm_version_greater_than_or_equal_to "$1" v4.0.0 +} + +nvm_install_merged_node_binary() { + local NVM_NODE_TYPE + NVM_NODE_TYPE="$1" + local MIRROR + if [ "_$NVM_NODE_TYPE" = "_std" ]; then + MIRROR="$NVM_NODEJS_ORG_MIRROR" + else + echo "unknown type of node.js release" >&2 + return 4 + fi + local VERSION + VERSION="$2" + local REINSTALL_PACKAGES_FROM + REINSTALL_PACKAGES_FROM="$3" + + if ! nvm_is_merged_node_version "$VERSION" || nvm_is_iojs_version "$VERSION"; then + echo 'nvm_install_merged_node_binary requires a node version v4.0 or greater.' >&2 + return 10 + fi + + local VERSION_PATH + VERSION_PATH="$(nvm_version_path "$VERSION")" + local NVM_OS + NVM_OS="$(nvm_get_os)" + local t + local url + local sum + local NODE_PREFIX + local compression + compression="gz" + local tar_compression_flag + tar_compression_flag="x" + if nvm_supports_xz "$VERSION"; then + compression="xz" + tar_compression_flag="J" + fi + NODE_PREFIX="$(nvm_node_prefix)" + + if [ -n "$NVM_OS" ]; then + t="$VERSION-$NVM_OS-$(nvm_get_arch)" + url="$MIRROR/$VERSION/$NODE_PREFIX-${t}.tar.${compression}" + sum="$(nvm_download -L -s "$MIRROR/$VERSION/SHASUMS256.txt" -o - | command grep "${NODE_PREFIX}-${t}.tar.${compression}" | command awk '{print $1}')" + local tmpdir + tmpdir="$NVM_DIR/bin/node-${t}" + local tmptarball + tmptarball="$tmpdir/node-${t}.tar.${compression}" + local NVM_INSTALL_ERRORED + command mkdir -p "$tmpdir" && \ + echo "Downloading $url..." && \ + nvm_download -L -C - --progress-bar "$url" -o "$tmptarball" || \ + NVM_INSTALL_ERRORED=true + if grep '404 Not Found' "$tmptarball" >/dev/null; then + NVM_INSTALL_ERRORED=true + echo >&2 "HTTP 404 at URL $url"; + fi + if ( + [ "$NVM_INSTALL_ERRORED" != true ] && \ + echo "WARNING: checksums are currently disabled for node.js v4.0 and later" >&2 && \ + # nvm_checksum "$tmptarball" "$sum" && \ + command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \ + command rm -f "$tmptarball" && \ + command mkdir -p "$VERSION_PATH" && \ + command mv "$tmpdir"/* "$VERSION_PATH" + ); then + return 0 + else + echo >&2 "Binary download failed, trying source." >&2 + command rm -rf "$tmptarball" "$tmpdir" + return 1 + fi + fi + return 2 +} + +nvm_install_iojs_binary() { + local NVM_IOJS_TYPE + NVM_IOJS_TYPE="$1" + local MIRROR + if [ "_$NVM_IOJS_TYPE" = "_std" ]; then + MIRROR="$NVM_IOJS_ORG_MIRROR" + else + echo "unknown type of io.js release" >&2 + return 4 + fi + local PREFIXED_VERSION + PREFIXED_VERSION="$2" + local REINSTALL_PACKAGES_FROM + REINSTALL_PACKAGES_FROM="$3" + + if ! nvm_is_iojs_version "$PREFIXED_VERSION"; then + echo 'nvm_install_iojs_binary requires an iojs-prefixed version.' >&2 + return 10 + fi + + local VERSION + VERSION="$(nvm_strip_iojs_prefix "$PREFIXED_VERSION")" + local VERSION_PATH + VERSION_PATH="$(nvm_version_path "$PREFIXED_VERSION")" + local NVM_OS + NVM_OS="$(nvm_get_os)" + local t + local url + local sum + local compression + compression="gz" + local tar_compression_flag + tar_compression_flag="x" + if nvm_supports_xz "$VERSION"; then + compression="xz" + tar_compression_flag="J" + fi + + if [ -n "$NVM_OS" ]; then + if nvm_binary_available "$VERSION"; then + t="$VERSION-$NVM_OS-$(nvm_get_arch)" + url="$MIRROR/$VERSION/$(nvm_iojs_prefix)-${t}.tar.${compression}" + sum="$(nvm_download -L -s "$MIRROR/$VERSION/SHASUMS256.txt" -o - | command grep "$(nvm_iojs_prefix)-${t}.tar.${compression}" | command awk '{print $1}')" + local tmpdir + tmpdir="$NVM_DIR/bin/iojs-${t}" + local tmptarball + tmptarball="$tmpdir/iojs-${t}.tar.${compression}" + local NVM_INSTALL_ERRORED + command mkdir -p "$tmpdir" && \ + echo "Downloading $url..." && \ + nvm_download -L -C - --progress-bar "$url" -o "$tmptarball" || \ + NVM_INSTALL_ERRORED=true + if grep '404 Not Found' "$tmptarball" >/dev/null; then + NVM_INSTALL_ERRORED=true + echo >&2 "HTTP 404 at URL $url"; + fi + if ( + [ "$NVM_INSTALL_ERRORED" != true ] && \ + echo "WARNING: checksums are currently disabled for io.js" >&2 && \ + # nvm_checksum "$tmptarball" "$sum" && \ + command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \ + command rm -f "$tmptarball" && \ + command mkdir -p "$VERSION_PATH" && \ + command mv "$tmpdir"/* "$VERSION_PATH" + ); then + return 0 + else + echo >&2 "Binary download failed, trying source." >&2 + command rm -rf "$tmptarball" "$tmpdir" + return 1 + fi + fi + fi + return 2 +} + +nvm_install_node_binary() { + local VERSION + VERSION="$1" + local REINSTALL_PACKAGES_FROM + REINSTALL_PACKAGES_FROM="$2" + + if nvm_is_iojs_version "$VERSION"; then + echo 'nvm_install_node_binary does not allow an iojs-prefixed version.' >&2 + return 10 + fi + + local VERSION_PATH + VERSION_PATH="$(nvm_version_path "$VERSION")" + local NVM_OS + NVM_OS="$(nvm_get_os)" + local t + local url + local sum + + if [ -n "$NVM_OS" ]; then + if nvm_binary_available "$VERSION"; then + local NVM_ARCH + NVM_ARCH="$(nvm_get_arch)" + if [ "_$NVM_ARCH" = '_armv6l' ] || [ "_$NVM_ARCH" = 'armv7l' ]; then + NVM_ARCH="arm-pi" + fi + t="$VERSION-$NVM_OS-$NVM_ARCH" + url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz" + sum=$(nvm_download -L -s "$NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt" -o - | command grep "node-${t}.tar.gz" | command awk '{print $1}') + local tmpdir + tmpdir="$NVM_DIR/bin/node-${t}" + local tmptarball + tmptarball="$tmpdir/node-${t}.tar.gz" + local NVM_INSTALL_ERRORED + command mkdir -p "$tmpdir" && \ + nvm_download -L -C - --progress-bar "$url" -o "$tmptarball" || \ + NVM_INSTALL_ERRORED=true + if grep '404 Not Found' "$tmptarball" >/dev/null; then + NVM_INSTALL_ERRORED=true + echo >&2 "HTTP 404 at URL $url"; + fi + if ( + [ "$NVM_INSTALL_ERRORED" != true ] && \ + nvm_checksum "$tmptarball" "$sum" && \ + command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \ + command rm -f "$tmptarball" && \ + command mkdir -p "$VERSION_PATH" && \ + command mv "$tmpdir"/* "$VERSION_PATH" + ); then + return 0 + else + echo >&2 "Binary download failed, trying source." + command rm -rf "$tmptarball" "$tmpdir" + return 1 + fi + fi + fi + return 2 +} + +nvm_get_make_jobs() { + if nvm_is_natural_num "${1-}"; then + NVM_MAKE_JOBS="$1" + echo "number of \`make\` jobs: $NVM_MAKE_JOBS" + return + elif [ -n "${1-}" ]; then + unset NVM_MAKE_JOBS + echo >&2 "$1 is invalid for number of \`make\` jobs, must be a natural number" + fi + local NVM_OS + NVM_OS="$(nvm_get_os)" + local NVM_CPU_THREADS + if [ "_$NVM_OS" = "_linux" ]; then + NVM_CPU_THREADS="$(grep -c 'core id' /proc/cpuinfo)" + elif [ "_$NVM_OS" = "_freebsd" ] || [ "_$NVM_OS" = "_darwin" ]; then + NVM_CPU_THREADS="$(sysctl -n hw.ncpu)" + elif [ "_$NVM_OS" = "_sunos" ]; then + NVM_CPU_THREADS="$(psrinfo | wc -l)" + fi + if ! nvm_is_natural_num "$NVM_CPU_THREADS" ; then + echo "Can not determine how many thread(s) we can use, set to only 1 now." >&2 + echo "Please report an issue on GitHub to help us make it better and run it faster on your computer!" >&2 + NVM_MAKE_JOBS=1 + else + echo "Detected that you have $NVM_CPU_THREADS CPU thread(s)" + if [ $NVM_CPU_THREADS -gt 2 ]; then + NVM_MAKE_JOBS=$(($NVM_CPU_THREADS - 1)) + echo "Set the number of jobs to $NVM_CPU_THREADS - 1 = $NVM_MAKE_JOBS jobs to speed up the build" + else + NVM_MAKE_JOBS=1 + echo "Number of CPU thread(s) less or equal to 2 will have only one job a time for 'make'" + fi + fi +} + +nvm_install_node_source() { + local VERSION + VERSION="$1" + local NVM_MAKE_JOBS + NVM_MAKE_JOBS="$2" + local ADDITIONAL_PARAMETERS + ADDITIONAL_PARAMETERS="$3" + + local NVM_ARCH + NVM_ARCH="$(nvm_get_arch)" + if [ "_$NVM_ARCH" = '_armv6l' ] || [ "_$NVM_ARCH" = '_armv7l' ]; then + ADDITIONAL_PARAMETERS="--without-snapshot $ADDITIONAL_PARAMETERS" + fi + + if [ -n "$ADDITIONAL_PARAMETERS" ]; then + echo "Additional options while compiling: $ADDITIONAL_PARAMETERS" + fi + + local VERSION_PATH + VERSION_PATH="$(nvm_version_path "$VERSION")" + local NVM_OS + NVM_OS="$(nvm_get_os)" + + local tarball + tarball='' + local sum + sum='' + local make + make='make' + if [ "_$NVM_OS" = "_freebsd" ]; then + make='gmake' + MAKE_CXX="CXX=c++" + fi + + local tmpdir + tmpdir="$NVM_DIR/src" + local tmptarball + tmptarball="$tmpdir/node-$VERSION.tar.gz" + + if [ "$(nvm_download -L -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - 2>&1 | command grep '200 OK')" != '' ]; then + tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" + sum=$(nvm_download -L -s "$NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt" -o - | command grep "node-${VERSION}.tar.gz" | command awk '{print $1}') + elif [ "$(nvm_download -L -s -I "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" -o - | command grep '200 OK')" != '' ]; then + tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" + fi + + if ( + [ -n "$tarball" ] && \ + command mkdir -p "$tmpdir" && \ + echo "Downloading $tarball..." && \ + nvm_download -L --progress-bar "$tarball" -o "$tmptarball" && \ + nvm_checksum "$tmptarball" "$sum" && \ + command tar -xzf "$tmptarball" -C "$tmpdir" && \ + cd "$tmpdir/node-$VERSION" && \ + ./configure --prefix="$VERSION_PATH" $ADDITIONAL_PARAMETERS && \ + $make -j $NVM_MAKE_JOBS ${MAKE_CXX-} && \ + command rm -f "$VERSION_PATH" 2>/dev/null && \ + $make -j $NVM_MAKE_JOBS ${MAKE_CXX-} install + ) + then + if ! nvm_has "npm" ; then + echo "Installing npm..." + if nvm_version_greater 0.2.0 "$VERSION"; then + echo "npm requires node v0.2.3 or higher" >&2 + elif nvm_version_greater_than_or_equal_to "$VERSION" 0.2.0; then + if nvm_version_greater 0.2.3 "$VERSION"; then + echo "npm requires node v0.2.3 or higher" >&2 + else + nvm_download -L https://npmjs.org/install.sh -o - | clean=yes npm_install=0.2.19 sh + fi + else + nvm_download -L https://npmjs.org/install.sh -o - | clean=yes sh + fi + fi + else + echo "nvm: install $VERSION failed!" >&2 + return 1 + fi + + return $? +} + +nvm_match_version() { + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + local PROVIDED_VERSION + PROVIDED_VERSION="$1" + case "_$PROVIDED_VERSION" in + "_$NVM_IOJS_PREFIX" | "_io.js") + nvm_version "$NVM_IOJS_PREFIX" + ;; + "_system") + echo "system" + ;; + *) + nvm_version "$PROVIDED_VERSION" + ;; + esac +} + +nvm_npm_global_modules() { + local NPMLIST + local VERSION + VERSION="$1" + if [ "_$VERSION" = "_system" ]; then + NPMLIST=$(nvm use system > /dev/null && npm list -g --depth=0 2> /dev/null | command tail -n +2) + else + NPMLIST=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 2> /dev/null | command tail -n +2) + fi + + local INSTALLS + INSTALLS=$(echo "$NPMLIST" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs) + + local LINKS + LINKS="$(echo "$NPMLIST" | command sed -n 's/.* -> \(.*\)/\1/ p')" + + echo "$INSTALLS //// $LINKS" +} + +nvm_die_on_prefix() { + local NVM_DELETE_PREFIX + NVM_DELETE_PREFIX="$1" + case "$NVM_DELETE_PREFIX" in + 0|1) ;; + *) + echo >&2 'First argument "delete the prefix" must be zero or one' + return 1 + ;; + esac + local NVM_COMMAND + NVM_COMMAND="$2" + if [ -z "$NVM_COMMAND" ]; then + echo >&2 'Second argument "nvm command" must be nonempty' + return 2 + fi + + if [ -n "${PREFIX-}" ] && ! (nvm_tree_contains_path "$NVM_DIR" "$PREFIX" >/dev/null 2>&1); then + nvm deactivate >/dev/null 2>&1 + echo >&2 "nvm is not compatible with the \"PREFIX\" environment variable: currently set to \"$PREFIX\"" + echo >&2 "Run \`unset PREFIX\` to unset it." + return 3 + fi + + if [ -n "${NPM_CONFIG_PREFIX-}" ] && ! (nvm_tree_contains_path "$NVM_DIR" "$NPM_CONFIG_PREFIX" >/dev/null 2>&1); then + nvm deactivate >/dev/null 2>&1 + echo >&2 "nvm is not compatible with the \"NPM_CONFIG_PREFIX\" environment variable: currently set to \"$NPM_CONFIG_PREFIX\"" + echo >&2 "Run \`unset NPM_CONFIG_PREFIX\` to unset it." + return 4 + fi + + if ! nvm_has 'npm'; then + return + fi + + local NVM_NPM_PREFIX + NVM_NPM_PREFIX="$(NPM_CONFIG_LOGLEVEL=warn npm config get prefix)" + if ! (nvm_tree_contains_path "$NVM_DIR" "$NVM_NPM_PREFIX" >/dev/null 2>&1); then + if [ "_$NVM_DELETE_PREFIX" = "_1" ]; then + NPM_CONFIG_LOGLEVEL=warn npm config delete prefix + else + nvm deactivate >/dev/null 2>&1 + echo >&2 "nvm is not compatible with the npm config \"prefix\" option: currently set to \"$NVM_NPM_PREFIX\"" + if nvm_has 'npm'; then + echo >&2 "Run \`npm config delete prefix\` or \`$NVM_COMMAND\` to unset it." + else + echo >&2 "Run \`$NVM_COMMAND\` to unset it." + fi + return 10 + fi + fi +} + +# Succeeds if $IOJS_VERSION represents an io.js version that has a +# Solaris binary, fails otherwise. +# Currently, only io.js 3.3.1 has a Solaris binary available, and it's the +# latest io.js version available. The expectation is that any potential io.js +# version later than v3.3.1 will also have Solaris binaries. +iojs_version_has_solaris_binary() { + local IOJS_VERSION + IOJS_VERSION="$1" + local STRIPPED_IOJS_VERSION + STRIPPED_IOJS_VERSION="$(nvm_strip_iojs_prefix "$IOJS_VERSION")" + if [ "_$STRIPPED_IOJS_VERSION" = "$IOJS_VERSION" ]; then + return 1 + fi + + # io.js started shipping Solaris binaries with io.js v3.3.1 + nvm_version_greater_than_or_equal_to "$STRIPPED_IOJS_VERSION" v3.3.1 +} + +# Succeeds if $NODE_VERSION represents a node version that has a +# Solaris binary, fails otherwise. +# Currently, node versions starting from v0.8.6 have a Solaris binary +# avaliable. +node_version_has_solaris_binary() { + local NODE_VERSION + NODE_VERSION="$1" + # Error out if $NODE_VERSION is actually an io.js version + local STRIPPED_IOJS_VERSION + STRIPPED_IOJS_VERSION="$(nvm_strip_iojs_prefix "$NODE_VERSION")" + if [ "_$STRIPPED_IOJS_VERSION" != "_$NODE_VERSION" ]; then + return 1 + fi + + # node (unmerged) started shipping Solaris binaries with v0.8.6 and + # node versions v1.0.0 or greater are not considered valid "unmerged" node + # versions. + nvm_version_greater_than_or_equal_to "$NODE_VERSION" v0.8.6 && + ! nvm_version_greater_than_or_equal_to "$NODE_VERSION" v1.0.0 +} + +# Succeeds if $VERSION represents a version (node, io.js or merged) that has a +# Solaris binary, fails otherwise. +nvm_has_solaris_binary() { + local VERSION=$1 + if nvm_is_merged_node_version "$VERSION"; then + return 0 # All merged node versions have a Solaris binary + elif nvm_is_iojs_version "$VERSION"; then + iojs_version_has_solaris_binary "$VERSION" + else + node_version_has_solaris_binary "$VERSION" + fi +} + +nvm_sanitize_path() { + local SANITIZED_PATH + SANITIZED_PATH="$1" + if [ "_$1" != "_$NVM_DIR" ]; then + SANITIZED_PATH="$(echo "$SANITIZED_PATH" | command sed "s#$NVM_DIR#\$NVM_DIR#g")" + fi + echo "$SANITIZED_PATH" | command sed "s#$HOME#\$HOME#g" +} + +nvm_is_natural_num() { + if [ -z "$1" ]; then + return 4 + fi + case "$1" in + 0) return 1 ;; + -*) return 3 ;; # some BSDs return false positives for double-negated args + *) + [ $1 -eq $1 2> /dev/null ] # returns 2 if it doesn't match + ;; + esac +} + +nvm() { + if [ $# -lt 1 ]; then + nvm help + return + fi + + local GREP_OPTIONS + GREP_OPTIONS='' + + # initialize local variables + local VERSION + local ADDITIONAL_PARAMETERS + local ALIAS + + case $1 in + "help" ) + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + local NVM_NODE_PREFIX + NVM_NODE_PREFIX="$(nvm_node_prefix)" + echo + echo "Node Version Manager" + echo + echo 'Note: refers to any version-like string nvm understands. This includes:' + echo ' - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)' + echo " - default (built-in) aliases: $NVM_NODE_PREFIX, stable, unstable, $NVM_IOJS_PREFIX, system" + echo ' - custom aliases you define with `nvm alias foo`' + echo + echo 'Usage:' + echo ' nvm help Show this message' + echo ' nvm --version Print out the latest released version of nvm' + echo ' nvm install [-s] Download and install a , [-s] from source. Uses .nvmrc if available' + echo ' --reinstall-packages-from= When installing, reinstall packages installed in ' + echo ' nvm uninstall Uninstall a version' + echo ' nvm use [--silent] Modify PATH to use . Uses .nvmrc if available' + echo ' nvm exec [--silent] [] Run on . Uses .nvmrc if available' + echo ' nvm run [--silent] [] Run `node` on with as arguments. Uses .nvmrc if available' + echo ' nvm current Display currently activated version' + echo ' nvm ls List installed versions' + echo ' nvm ls List versions matching a given description' + echo ' nvm ls-remote List remote versions available for install' + echo ' nvm version Resolve the given description to a single local version' + echo ' nvm version-remote Resolve the given description to a single remote version' + echo ' nvm deactivate Undo effects of `nvm` on current shell' + echo ' nvm alias [] Show all aliases beginning with ' + echo ' nvm alias Set an alias named pointing to ' + echo ' nvm unalias Deletes the alias named ' + echo ' nvm reinstall-packages Reinstall global `npm` packages contained in to current version' + echo ' nvm unload Unload `nvm` from shell' + echo ' nvm which [] Display path to installed node version. Uses .nvmrc if available' + echo + echo 'Example:' + echo ' nvm install v0.10.32 Install a specific version number' + echo ' nvm use 0.10 Use the latest available 0.10.x release' + echo ' nvm run 0.10.32 app.js Run app.js using node v0.10.32' + echo ' nvm exec 0.10.32 node app.js Run `node app.js` with the PATH pointing to node v0.10.32' + echo ' nvm alias default 0.10.32 Set default node version on a shell' + echo + echo 'Note:' + echo ' to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)' + echo + ;; + + "debug" ) + local ZHS_HAS_SHWORDSPLIT_UNSET + ZHS_HAS_SHWORDSPLIT_UNSET=1 + if nvm_has "setopt"; then + ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?) + setopt shwordsplit + fi + echo >&2 "nvm --version: v$(nvm --version)" + echo >&2 "\$SHELL: $SHELL" + echo >&2 "\$HOME: $HOME" + echo >&2 "\$NVM_DIR: '$(nvm_sanitize_path "$NVM_DIR")'" + echo >&2 "\$PREFIX: '$(nvm_sanitize_path "$PREFIX")'" + echo >&2 "\$NPM_CONFIG_PREFIX: '$(nvm_sanitize_path "$NPM_CONFIG_PREFIX")'" + local NVM_DEBUG_OUTPUT + for NVM_DEBUG_COMMAND in 'nvm current' 'which node' 'which iojs' 'which npm' 'npm config get prefix' 'npm root -g' + do + NVM_DEBUG_OUTPUT="$($NVM_DEBUG_COMMAND 2>&1)" + echo >&2 "$NVM_DEBUG_COMMAND: $(nvm_sanitize_path "$NVM_DEBUG_OUTPUT")" + done + if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then + unsetopt shwordsplit + fi + return 42 + ;; + + "install" | "i" ) + local version_not_provided + version_not_provided=0 + local NVM_OS + NVM_OS="$(nvm_get_os)" + + if ! nvm_has "curl" && ! nvm_has "wget"; then + echo 'nvm needs curl or wget to proceed.' >&2; + return 1 + fi + + if [ $# -lt 2 ]; then + version_not_provided=1 + nvm_rc_version + if [ -z "$NVM_RC_VERSION" ]; then + >&2 nvm help + return 127 + fi + fi + + shift + + local nobinary + nobinary=0 + local make_jobs + while [ $# -ne 0 ] + do + case "$1" in + -s) + shift # consume "-s" + nobinary=1 + ;; + -j) + shift # consume "-j" + nvm_get_make_jobs "$1" + shift # consume job count + ;; + *) + break # stop parsing args + ;; + esac + done + + local provided_version + provided_version="$1" + + if [ -z "$provided_version" ]; then + if [ $version_not_provided -ne 1 ]; then + nvm_rc_version + fi + provided_version="$NVM_RC_VERSION" + else + shift + fi + + VERSION="$(nvm_remote_version "$provided_version")" + + if [ "_$VERSION" = "_N/A" ]; then + echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." >&2 + return 3 + fi + + ADDITIONAL_PARAMETERS='' + local PROVIDED_REINSTALL_PACKAGES_FROM + local REINSTALL_PACKAGES_FROM + + while [ $# -ne 0 ] + do + case "$1" in + --reinstall-packages-from=*) + PROVIDED_REINSTALL_PACKAGES_FROM="$(echo "$1" | command cut -c 27-)" + REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" + ;; + --copy-packages-from=*) + PROVIDED_REINSTALL_PACKAGES_FROM="$(echo "$1" | command cut -c 22-)" + REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" + ;; + *) + ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1" + ;; + esac + shift + done + + if [ "_$(nvm_ensure_version_prefix "$PROVIDED_REINSTALL_PACKAGES_FROM")" = "_$VERSION" ]; then + echo "You can't reinstall global packages from the same version of node you're installing." >&2 + return 4 + elif [ ! -z "$PROVIDED_REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" = "_N/A" ]; then + echo "If --reinstall-packages-from is provided, it must point to an installed version of node." >&2 + return 5 + fi + + local NVM_NODE_MERGED + local NVM_IOJS + if nvm_is_iojs_version "$VERSION"; then + NVM_IOJS=true + elif nvm_is_merged_node_version "$VERSION"; then + NVM_NODE_MERGED=true + fi + + local VERSION_PATH + VERSION_PATH="$(nvm_version_path "$VERSION")" + if [ -d "$VERSION_PATH" ]; then + echo "$VERSION is already installed." >&2 + if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then + nvm reinstall-packages "$REINSTALL_PACKAGES_FROM" + fi + return $? + fi + + if [ "_$NVM_OS" = "_freebsd" ]; then + # node.js and io.js do not have a FreeBSD binary + nobinary=1 + echo "Currently, there is no binary for $NVM_OS" >&2 + elif [ "_$NVM_OS" = "_sunos" ]; then + # Not all node/io.js versions have a Solaris binary + if ! nvm_has_solaris_binary "$VERSION"; then + nobinary=1 + echo "Currently, there is no binary of version $VERSION for $NVM_OS" >&2 + fi + fi + local NVM_INSTALL_SUCCESS + # skip binary install if "nobinary" option specified. + if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then + if [ "$NVM_IOJS" = true ] && nvm_install_iojs_binary std "$VERSION" "$REINSTALL_PACKAGES_FROM"; then + NVM_INSTALL_SUCCESS=true + elif [ "$NVM_NODE_MERGED" = true ] && nvm_install_merged_node_binary std "$VERSION" "$REINSTALL_PACKAGES_FROM"; then + NVM_INSTALL_SUCCESS=true + elif [ "$NVM_IOJS" != true ] && nvm_install_node_binary "$VERSION" "$REINSTALL_PACKAGES_FROM"; then + NVM_INSTALL_SUCCESS=true + fi + fi + if [ "$NVM_INSTALL_SUCCESS" != true ]; then + if [ -z "${NVM_MAKE_JOBS-}" ]; then + nvm_get_make_jobs + fi + if [ "$NVM_IOJS" != true ] && [ "$NVM_NODE_MERGED" != true ]; then + if nvm_install_node_source "$VERSION" "$NVM_MAKE_JOBS" "$ADDITIONAL_PARAMETERS"; then + NVM_INSTALL_SUCCESS=true + fi + elif [ "$NVM_IOJS" = true ]; then + # nvm_install_iojs_source "$VERSION" "$NVM_MAKE_JOBS" "$ADDITIONAL_PARAMETERS" + echo "Installing iojs from source is not currently supported" >&2 + return 105 + elif [ "$NVM_NODE_MERGED" = true ]; then + # nvm_install_merged_node_source "$VERSION" "$NVM_MAKE_JOBS" "$ADDITIONAL_PARAMETERS" + echo "Installing node v1.0 and greater from source is not currently supported" >&2 + return 106 + fi + fi + + if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then + if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \ + && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then + nvm reinstall-packages "$REINSTALL_PACKAGES_FROM" + fi + fi + return $? + ;; + "uninstall" ) + if [ $# -ne 2 ]; then + >&2 nvm help + return 127 + fi + + local PATTERN + PATTERN="$2" + case "_$PATTERN" in + "_$(nvm_iojs_prefix)" | "_$(nvm_iojs_prefix)-" \ + | "_$(nvm_node_prefix)" | "_$(nvm_node_prefix)-") + VERSION="$(nvm_version "$PATTERN")" + ;; + *) + VERSION="$(nvm_version "$PATTERN")" + ;; + esac + if [ "_$VERSION" = "_$(nvm_ls_current)" ]; then + if nvm_is_iojs_version "$VERSION"; then + echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2 + else + echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2 + fi + return 1 + fi + + local VERSION_PATH + VERSION_PATH="$(nvm_version_path "$VERSION")" + if [ ! -d "$VERSION_PATH" ]; then + echo "$VERSION version is not installed..." >&2 + return; + fi + + t="$VERSION-$(nvm_get_os)-$(nvm_get_arch)" + + local NVM_PREFIX + local NVM_SUCCESS_MSG + if nvm_is_iojs_version "$VERSION"; then + NVM_PREFIX="$(nvm_iojs_prefix)" + NVM_SUCCESS_MSG="Uninstalled io.js $(nvm_strip_iojs_prefix "$VERSION")" + else + NVM_PREFIX="$(nvm_node_prefix)" + NVM_SUCCESS_MSG="Uninstalled node $VERSION" + fi + # Delete all files related to target version. + command rm -rf "$NVM_DIR/src/$NVM_PREFIX-$VERSION" \ + "$NVM_DIR/src/$NVM_PREFIX-$VERSION.tar.*" \ + "$NVM_DIR/bin/$NVM_PREFIX-${t}" \ + "$NVM_DIR/bin/$NVM_PREFIX-${t}.tar.*" \ + "$VERSION_PATH" 2>/dev/null + echo "$NVM_SUCCESS_MSG" + + # rm any aliases that point to uninstalled version. + for ALIAS in $(command grep -l "$VERSION" "$(nvm_alias_path)/*" 2>/dev/null) + do + nvm unalias "$(command basename "$ALIAS")" + done + ;; + "deactivate" ) + local NEWPATH + NEWPATH="$(nvm_strip_path "$PATH" "/bin")" + if [ "_$PATH" = "_$NEWPATH" ]; then + echo "Could not find $NVM_DIR/*/bin in \$PATH" >&2 + else + export PATH="$NEWPATH" + hash -r + echo "$NVM_DIR/*/bin removed from \$PATH" + fi + + if [ -n "${MANPATH-}" ]; then + NEWPATH="$(nvm_strip_path "$MANPATH" "/share/man")" + if [ "_$MANPATH" = "_$NEWPATH" ]; then + echo "Could not find $NVM_DIR/*/share/man in \$MANPATH" >&2 + else + export MANPATH="$NEWPATH" + echo "$NVM_DIR/*/share/man removed from \$MANPATH" + fi + fi + + if [ -n "${NODE_PATH-}" ]; then + NEWPATH="$(nvm_strip_path "$NODE_PATH" "/lib/node_modules")" + if [ "_$NODE_PATH" != "_$NEWPATH" ]; then + export NODE_PATH="$NEWPATH" + echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH" + fi + fi + ;; + "use" ) + local PROVIDED_VERSION + local NVM_USE_SILENT + NVM_USE_SILENT=0 + local NVM_DELETE_PREFIX + NVM_DELETE_PREFIX=0 + + shift # remove "use" + while [ $# -ne 0 ] + do + case "$1" in + --silent) NVM_USE_SILENT=1 ;; + --delete-prefix) NVM_DELETE_PREFIX=1 ;; + *) + if [ -n "$1" ]; then + PROVIDED_VERSION="$1" + fi + ;; + esac + shift + done + + if [ -z "$PROVIDED_VERSION" ]; then + nvm_rc_version + if [ -n "$NVM_RC_VERSION" ]; then + PROVIDED_VERSION="$NVM_RC_VERSION" + VERSION="$(nvm_version "$PROVIDED_VERSION")" + fi + else + VERSION="$(nvm_match_version "$PROVIDED_VERSION")" + fi + + if [ -z "$VERSION" ]; then + >&2 nvm help + return 127 + fi + + if [ "_$VERSION" = '_system' ]; then + if nvm_has_system_node && nvm deactivate >/dev/null 2>&1; then + if [ $NVM_USE_SILENT -ne 1 ]; then + echo "Now using system version of node: $(node -v 2>/dev/null)$(nvm_print_npm_version)" + fi + return + elif nvm_has_system_iojs && nvm deactivate >/dev/null 2>&1; then + if [ $NVM_USE_SILENT -ne 1 ]; then + echo "Now using system version of io.js: $(iojs --version 2>/dev/null)$(nvm_print_npm_version)" + fi + return + else + if [ $NVM_USE_SILENT -ne 1 ]; then + echo "System version of node not found." >&2 + fi + return 127 + fi + elif [ "_$VERSION" = "_∞" ]; then + if [ $NVM_USE_SILENT -ne 1 ]; then + echo "The alias \"$PROVIDED_VERSION\" leads to an infinite loop. Aborting." >&2 + fi + return 8 + fi + + # This nvm_ensure_version_installed call can be a performance bottleneck + # on shell startup. Perhaps we can optimize it away or make it faster. + nvm_ensure_version_installed "$PROVIDED_VERSION" + EXIT_CODE=$? + if [ "$EXIT_CODE" != "0" ]; then + return $EXIT_CODE + fi + + local NVM_VERSION_DIR + NVM_VERSION_DIR="$(nvm_version_path "$VERSION")" + + # Strip other version from PATH + PATH="$(nvm_strip_path "$PATH" "/bin")" + # Prepend current version + PATH="$(nvm_prepend_path "$PATH" "$NVM_VERSION_DIR/bin")" + if nvm_has manpath; then + if [ -z "$MANPATH" ]; then + MANPATH=$(manpath) + fi + # Strip other version from MANPATH + MANPATH="$(nvm_strip_path "$MANPATH" "/share/man")" + # Prepend current version + MANPATH="$(nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man")" + export MANPATH + fi + export PATH + hash -r + export NVM_PATH="$NVM_VERSION_DIR/lib/node" + export NVM_BIN="$NVM_VERSION_DIR/bin" + if [ "${NVM_SYMLINK_CURRENT-}" = true ]; then + command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current" + fi + local NVM_USE_OUTPUT + if [ $NVM_USE_SILENT -ne 1 ]; then + if nvm_is_iojs_version "$VERSION"; then + NVM_USE_OUTPUT="Now using io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)" + else + NVM_USE_OUTPUT="Now using node $VERSION$(nvm_print_npm_version)" + fi + fi + if [ "_$VERSION" != "_system" ]; then + local NVM_USE_CMD + NVM_USE_CMD="nvm use --delete-prefix" + if [ -n "$PROVIDED_VERSION" ]; then + NVM_USE_CMD="$NVM_USE_CMD $VERSION" + fi + if [ $NVM_USE_SILENT -eq 1 ]; then + NVM_USE_CMD="$NVM_USE_CMD --silent" + fi + if ! nvm_die_on_prefix "$NVM_DELETE_PREFIX" "$NVM_USE_CMD"; then + return 11 + fi + fi + if [ -n "$NVM_USE_OUTPUT" ]; then + echo "$NVM_USE_OUTPUT" + fi + ;; + "run" ) + local provided_version + local has_checked_nvmrc + has_checked_nvmrc=0 + # run given version of node + shift + + local NVM_SILENT + NVM_SILENT=0 + if [ "_$1" = "_--silent" ]; then + NVM_SILENT=1 + shift + fi + + if [ $# -lt 1 ]; then + if [ "$NVM_SILENT" -eq 1 ]; then + nvm_rc_version >/dev/null 2>&1 && has_checked_nvmrc=1 + else + nvm_rc_version && has_checked_nvmrc=1 + fi + if [ -n "$NVM_RC_VERSION" ]; then + VERSION="$(nvm_version "$NVM_RC_VERSION")" + else + VERSION='N/A' + fi + if [ $VERSION = "N/A" ]; then + >&2 nvm help + return 127 + fi + fi + + provided_version="$1" + if [ -n "$provided_version" ]; then + VERSION="$(nvm_version "$provided_version")" + if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then + provided_version='' + if [ $has_checked_nvmrc -ne 1 ]; then + if [ "$NVM_SILENT" -eq 1 ]; then + nvm_rc_version >/dev/null 2>&1 && has_checked_nvmrc=1 + else + nvm_rc_version && has_checked_nvmrc=1 + fi + fi + VERSION="$(nvm_version "$NVM_RC_VERSION")" + else + shift + fi + fi + + local NVM_IOJS + if nvm_is_iojs_version "$VERSION"; then + NVM_IOJS=true + fi + + local ARGS + ARGS="$@" + local OUTPUT + local EXIT_CODE + + local ZHS_HAS_SHWORDSPLIT_UNSET + ZHS_HAS_SHWORDSPLIT_UNSET=1 + if nvm_has "setopt"; then + ZHS_HAS_SHWORDSPLIT_UNSET=$(setopt | command grep shwordsplit > /dev/null ; echo $?) + setopt shwordsplit + fi + if [ "_$VERSION" = "_N/A" ]; then + nvm_ensure_version_installed "$provided_version" + EXIT_CODE=$? + elif [ -z "$ARGS" ]; then + if [ "$NVM_IOJS" = true ]; then + nvm exec "$VERSION" iojs + else + nvm exec "$VERSION" node + fi + EXIT_CODE="$?" + elif [ "$NVM_IOJS" = true ]; then + [ $NVM_SILENT -eq 1 ] || echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm use --silent "$VERSION" && nvm_print_npm_version)" + OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs $ARGS)" + EXIT_CODE="$?" + else + [ $NVM_SILENT -eq 1 ] || echo "Running node $VERSION$(nvm use --silent "$VERSION" && nvm_print_npm_version)" + OUTPUT="$(nvm use "$VERSION" >/dev/null && node $ARGS)" + EXIT_CODE="$?" + fi + if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then + unsetopt shwordsplit + fi + if [ -n "$OUTPUT" ]; then + echo "$OUTPUT" + fi + return $EXIT_CODE + ;; + "exec" ) + shift + + local NVM_SILENT + NVM_SILENT=0 + if [ "_$1" = "_--silent" ]; then + NVM_SILENT=1 + shift + fi + + local provided_version + provided_version="$1" + if [ -n "$provided_version" ]; then + VERSION="$(nvm_version "$provided_version")" + if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then + if [ "$NVM_SILENT" -eq 1 ]; then + nvm_rc_version >/dev/null 2>&1 + else + nvm_rc_version + fi + provided_version="$NVM_RC_VERSION" + VERSION="$(nvm_version "$provided_version")" + else + shift + fi + fi + + nvm_ensure_version_installed "$provided_version" + EXIT_CODE=$? + if [ "$EXIT_CODE" != "0" ]; then + return $EXIT_CODE + fi + + [ $NVM_SILENT -eq 1 ] || echo "Running node $VERSION$(nvm use --silent "$VERSION" && nvm_print_npm_version)" + NODE_VERSION="$VERSION" "$NVM_DIR/nvm-exec" "$@" + ;; + "ls" | "list" ) + local NVM_LS_OUTPUT + local NVM_LS_EXIT_CODE + NVM_LS_OUTPUT=$(nvm_ls "${2-}") + NVM_LS_EXIT_CODE=$? + nvm_print_versions "$NVM_LS_OUTPUT" + if [ $# -eq 1 ]; then + nvm alias + fi + return $NVM_LS_EXIT_CODE + ;; + "ls-remote" | "list-remote" ) + local PATTERN + PATTERN="${2-}" + local NVM_IOJS_PREFIX + NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" + local NVM_NODE_PREFIX + NVM_NODE_PREFIX="$(nvm_node_prefix)" + local NVM_FLAVOR + case "_$PATTERN" in + "_$NVM_IOJS_PREFIX" | "_$NVM_NODE_PREFIX" ) + NVM_FLAVOR="$PATTERN" + PATTERN="$3" + ;; + esac + + local NVM_LS_REMOTE_EXIT_CODE + NVM_LS_REMOTE_EXIT_CODE=0 + local NVM_LS_REMOTE_PRE_MERGED_OUTPUT + NVM_LS_REMOTE_PRE_MERGED_OUTPUT='' + local NVM_LS_REMOTE_POST_MERGED_OUTPUT + NVM_LS_REMOTE_POST_MERGED_OUTPUT='' + if [ "_$NVM_FLAVOR" != "_$NVM_IOJS_PREFIX" ]; then + local NVM_LS_REMOTE_OUTPUT + NVM_LS_REMOTE_OUTPUT=$(nvm_ls_remote "$PATTERN") + # split output into two + NVM_LS_REMOTE_PRE_MERGED_OUTPUT="${NVM_LS_REMOTE_OUTPUT%%v4\.0\.0*}" + NVM_LS_REMOTE_POST_MERGED_OUTPUT="${NVM_LS_REMOTE_OUTPUT#$NVM_LS_REMOTE_PRE_MERGED_OUTPUT}" + NVM_LS_REMOTE_EXIT_CODE=$? + fi + + local NVM_LS_REMOTE_IOJS_EXIT_CODE + NVM_LS_REMOTE_IOJS_EXIT_CODE=0 + local NVM_LS_REMOTE_IOJS_OUTPUT + NVM_LS_REMOTE_IOJS_OUTPUT='' + if [ "_$NVM_FLAVOR" != "_$NVM_NODE_PREFIX" ]; then + NVM_LS_REMOTE_IOJS_OUTPUT=$(nvm_ls_remote_iojs "$PATTERN") + NVM_LS_REMOTE_IOJS_EXIT_CODE=$? + fi + + local NVM_OUTPUT + NVM_OUTPUT="$(echo "$NVM_LS_REMOTE_PRE_MERGED_OUTPUT +$NVM_LS_REMOTE_IOJS_OUTPUT +$NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d')" + if [ -n "$NVM_OUTPUT" ]; then + nvm_print_versions "$NVM_OUTPUT" + return $NVM_LS_REMOTE_EXIT_CODE || $NVM_LS_REMOTE_IOJS_EXIT_CODE + else + nvm_print_versions "N/A" + return 3 + fi + ;; + "current" ) + nvm_version current + ;; + "which" ) + local provided_version + provided_version="$2" + if [ $# -eq 1 ]; then + nvm_rc_version + if [ -n "$NVM_RC_VERSION" ]; then + provided_version="$NVM_RC_VERSION" + VERSION=$(nvm_version "$NVM_RC_VERSION") + fi + elif [ "_$2" != '_system' ]; then + VERSION="$(nvm_version "$provided_version")" + else + VERSION="$2" + fi + if [ -z "$VERSION" ]; then + >&2 nvm help + return 127 + fi + + if [ "_$VERSION" = '_system' ]; then + if nvm_has_system_iojs >/dev/null 2>&1 || nvm_has_system_node >/dev/null 2>&1; then + local NVM_BIN + NVM_BIN="$(nvm use system >/dev/null 2>&1 && command which node)" + if [ -n "$NVM_BIN" ]; then + echo "$NVM_BIN" + return + else + return 1 + fi + else + echo "System version of node not found." >&2 + return 127 + fi + elif [ "_$VERSION" = "_∞" ]; then + echo "The alias \"$2\" leads to an infinite loop. Aborting." >&2 + return 8 + fi + + nvm_ensure_version_installed "$provided_version" + EXIT_CODE=$? + if [ "$EXIT_CODE" != "0" ]; then + return $EXIT_CODE + fi + local NVM_VERSION_DIR + NVM_VERSION_DIR="$(nvm_version_path "$VERSION")" + echo "$NVM_VERSION_DIR/bin/node" + ;; + "alias" ) + local NVM_ALIAS_DIR + NVM_ALIAS_DIR="$(nvm_alias_path)" + command mkdir -p "$NVM_ALIAS_DIR" + if [ $# -le 2 ]; then + local DEST + for ALIAS_PATH in "$NVM_ALIAS_DIR"/"${2-}"*; do + ALIAS="$(command basename "$ALIAS_PATH")" + DEST="$(nvm_alias "$ALIAS" 2> /dev/null)" + if [ -n "$DEST" ]; then + VERSION="$(nvm_version "$DEST")" + if [ "_$DEST" = "_$VERSION" ]; then + echo "$ALIAS -> $DEST" + else + echo "$ALIAS -> $DEST (-> $VERSION)" + fi + fi + done + + for ALIAS in "$(nvm_node_prefix)" "stable" "unstable" "$(nvm_iojs_prefix)"; do + if [ ! -f "$NVM_ALIAS_DIR/$ALIAS" ]; then + if [ $# -lt 2 ] || [ "~$ALIAS" = "~$2" ]; then + DEST="$(nvm_print_implicit_alias local "$ALIAS")" + if [ "_$DEST" != "_" ]; then + VERSION="$(nvm_version "$DEST")" + if [ "_$DEST" = "_$VERSION" ]; then + echo "$ALIAS -> $DEST (default)" + else + echo "$ALIAS -> $DEST (-> $VERSION) (default)" + fi + fi + fi + fi + done + return + fi + if [ -z "${3-}" ]; then + command rm -f "$NVM_ALIAS_DIR/$2" + echo "$2 -> *poof*" + return + fi + VERSION="$(nvm_version "$3")" + if [ $? -ne 0 ]; then + echo "! WARNING: Version '$3' does not exist." >&2 + fi + echo "$3" | tee "$NVM_ALIAS_DIR/$2" >/dev/null + if [ ! "_$3" = "_$VERSION" ]; then + echo "$2 -> $3 (-> $VERSION)" + else + echo "$2 -> $3" + fi + ;; + "unalias" ) + local NVM_ALIAS_DIR + NVM_ALIAS_DIR="$(nvm_alias_path)" + command mkdir -p "$NVM_ALIAS_DIR" + if [ $# -ne 2 ]; then + >&2 nvm help + return 127 + fi + [ ! -f "$NVM_ALIAS_DIR/$2" ] && echo "Alias $2 doesn't exist!" >&2 && return + local NVM_ALIAS_ORIGINAL + NVM_ALIAS_ORIGINAL="$(nvm_alias "$2")" + command rm -f "$NVM_ALIAS_DIR/$2" + echo "Deleted alias $2 - restore it with \`nvm alias $2 "$NVM_ALIAS_ORIGINAL"\`" + ;; + "reinstall-packages" | "copy-packages" ) + if [ $# -ne 2 ]; then + >&2 nvm help + return 127 + fi + + local PROVIDED_VERSION + PROVIDED_VERSION="$2" + + if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ] || [ "$(nvm_version "$PROVIDED_VERSION")" = "$(nvm_ls_current)" ]; then + echo 'Can not reinstall packages from the current version of node.' >&2 + return 2 + fi + + local VERSION + if [ "_$PROVIDED_VERSION" = "_system" ]; then + if ! nvm_has_system_node && ! nvm_has_system_iojs; then + echo 'No system version of node or io.js detected.' >&2 + return 3 + fi + VERSION="system" + else + VERSION="$(nvm_version "$PROVIDED_VERSION")" + fi + + local NPMLIST + NPMLIST="$(nvm_npm_global_modules "$VERSION")" + local INSTALLS + local LINKS + INSTALLS="${NPMLIST%% //// *}" + LINKS="${NPMLIST##* //// }" + + echo "Reinstalling global packages from $VERSION..." + echo "$INSTALLS" | command xargs npm install -g --quiet + + echo "Linking global packages from $VERSION..." + set -f; IFS=' +' # necessary to turn off variable expansion except for newlines + for LINK in $LINKS; do + set +f; unset IFS # restore variable expansion + if [ -n "$LINK" ]; then + (cd "$LINK" && npm link) + fi + done + set +f; unset IFS # restore variable expansion in case $LINKS was empty + ;; + "clear-cache" ) + command rm -f "$NVM_DIR/v*" "$(nvm_version_dir)" 2>/dev/null + echo "Cache cleared." + ;; + "version" ) + nvm_version "$2" + ;; + "version-remote" ) + nvm_remote_version "$2" + ;; + "--version" ) + echo "0.30.2" + ;; + "unload" ) + unset -f nvm nvm_print_versions nvm_checksum \ + nvm_iojs_prefix nvm_node_prefix \ + nvm_add_iojs_prefix nvm_strip_iojs_prefix \ + nvm_is_iojs_version nvm_is_alias \ + nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab \ + nvm_ls nvm_remote_version nvm_remote_versions \ + nvm_install_iojs_binary nvm_install_node_binary \ + nvm_install_node_source \ + nvm_version nvm_rc_version nvm_match_version \ + nvm_ensure_default_set nvm_get_arch nvm_get_os \ + nvm_print_implicit_alias nvm_validate_implicit_alias \ + nvm_resolve_alias nvm_ls_current nvm_alias \ + nvm_binary_available nvm_prepend_path nvm_strip_path \ + nvm_num_version_groups nvm_format_version nvm_ensure_version_prefix \ + nvm_normalize_version nvm_is_valid_version \ + nvm_ensure_version_installed \ + nvm_version_path nvm_alias_path nvm_version_dir \ + nvm_find_nvmrc nvm_find_up nvm_tree_contains_path \ + nvm_version_greater nvm_version_greater_than_or_equal_to \ + nvm_print_npm_version nvm_npm_global_modules \ + nvm_has_system_node nvm_has_system_iojs \ + nvm_download nvm_get_latest nvm_has nvm_get_latest \ + nvm_supports_source_options nvm_auto nvm_supports_xz > /dev/null 2>&1 + unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1 + ;; + * ) + >&2 nvm help + return 127 + ;; + esac +} + +nvm_supports_source_options() { + [ "_$(echo '[ $# -gt 0 ] && echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ] +} + +nvm_supports_xz() { + command which xz >/dev/null 2>&1 && nvm_version_greater_than_or_equal_to "$1" "2.3.2" +} + +nvm_auto() { + local NVM_MODE + NVM_MODE="${1-}" + local VERSION + if [ "_$NVM_MODE" = '_install' ]; then + VERSION="$(nvm_alias default 2>/dev/null || echo)" + if [ -n "$VERSION" ]; then + nvm install "$VERSION" >/dev/null + elif nvm_rc_version >/dev/null 2>&1; then + nvm install >/dev/null + fi + elif [ "_$NVM_MODE" = '_use' ]; then + VERSION="$(nvm_alias default 2>/dev/null || echo)" + if [ -n "$VERSION" ]; then + nvm use --silent "$VERSION" >/dev/null + elif nvm_rc_version >/dev/null 2>&1; then + nvm use --silent >/dev/null + fi + elif [ "_$NVM_MODE" != '_none' ]; then + echo >&2 'Invalid auto mode supplied.' + return 1 + fi +} + +NVM_AUTO_MODE='use' +if nvm_supports_source_options; then + while [ $# -ne 0 ] + do + case "$1" in + --install) NVM_AUTO_MODE='install' ;; + --no-use) NVM_AUTO_MODE='none' ;; + esac + shift + done +fi +nvm_auto "$NVM_AUTO_MODE" + +} # this ensures the entire script is downloaded # diff --git a/package.json b/package.json new file mode 100644 index 0000000..2f76685 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "nvm", + "version": "0.30.2", + "description": "Node Version Manager - Simple bash script to manage multiple active node.js versions", + "directories": { + "test": "test" + }, + "scripts": { + "test": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make test-$shell", + "test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=fast test-$shell", + "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": { + "type": "git", + "url": "git://github.com/creationix/nvm.git" + }, + "keywords": [ + "nvm", + "node", + "iojs", + "version", + "manager" + ], + "author": "Tim Caswell ", + "license": "MIT", + "bugs": { + "url": "https://github.com/creationix/nvm/issues" + }, + "homepage": "https://github.com/creationix/nvm", + "devDependencies": { + "replace": "^0.3.0", + "semver": "^5.0.1", + "urchin": "^0.0.5" + } +} diff --git a/test/common.sh b/test/common.sh new file mode 100644 index 0000000..7d09064 --- /dev/null +++ b/test/common.sh @@ -0,0 +1,13 @@ +assert_ok() { + local FUNCTION=$1 + shift + + $($FUNCTION $@) || die '"'"$FUNCTION $@"'" should have succeeded, but failed' +} + +assert_not_ok() { + local FUNCTION=$1 + shift + + ! $($FUNCTION $@) || die '"'"$FUNCTION $@"'" should have failed, but succeeded' +} diff --git "a/test/fast/Aliases/Running \"nvm alias \" again should change the target" "b/test/fast/Aliases/Running \"nvm alias \" again should change the target" new file mode 100755 index 0000000..d4a8a2d --- /dev/null +++ "b/test/fast/Aliases/Running \"nvm alias \" again should change the target" @@ -0,0 +1,21 @@ +#!/bin/sh + +. ../../../nvm.sh + +die () { echo $@ ; exit 1; } + +if [ -n "$ZSH_VERSION" ]; then + # set clobber option in order to test that this does not produce any + # incompatibilities + setopt noclobber +fi + +nvm alias test-stable-1 0.0.2 + +nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.2 (-> v0.0.2)" \ + || die "nvm alias test-stable-1 0.0.2 did not set test-stable-1 to 0.0.2" + +nvm alias test-stable-1 0.0.1 + +nvm alias test-stable-1 | \grep -e "test-stable-1 -> 0.0.1 (-> v0.0.1)" \ + || die "nvm alias test-stable-1 0.0.1 did not set test-stable-1 to 0.0.1" diff --git "a/test/fast/Aliases/Running \"nvm alias \" should list but one alias." "b/test/fast/Aliases/Running \"nvm alias \" should list but one alias." new file mode 100755 index 0000000..b22df2e --- /dev/null +++ "b/test/fast/Aliases/Running \"nvm alias \" should list but one alias." @@ -0,0 +1,4 @@ +#!/bin/sh + +. ../../../nvm.sh +[ $(nvm alias test-stable-1 | wc -l) = '2' ] diff --git "a/test/fast/Aliases/Running \"nvm alias\" lists implicit aliases when they do not exist" "b/test/fast/Aliases/Running \"nvm alias\" lists implicit aliases when they do not exist" new file mode 100755 index 0000000..8fd73d8 --- /dev/null +++ "b/test/fast/Aliases/Running \"nvm alias\" lists implicit aliases when they do not exist" @@ -0,0 +1,26 @@ +#!/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" + +echo "$NVM_ALIAS_OUTPUT" | \grep -e "^node -> stable (-> $STABLE_VERSION) (default)$" \ + || die "nvm alias did not contain the default local stable node version under 'node'" + +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" + +EXPECTED_IOJS="$(nvm_print_implicit_alias local iojs)" +IOJS_VERSION="$(nvm_version "$EXPECTED_IOJS")" +echo "$NVM_ALIAS_OUTPUT" | \grep -e "^iojs -> $EXPECTED_IOJS (-> $IOJS_VERSION) (default)$" \ + || die "nvm alias did not contain the default local iojs version" + diff --git "a/test/fast/Aliases/Running \"nvm alias\" lists manual aliases instead of implicit aliases when present" "b/test/fast/Aliases/Running \"nvm alias\" lists manual aliases instead of implicit aliases when present" new file mode 100755 index 0000000..6c0fa99 --- /dev/null +++ "b/test/fast/Aliases/Running \"nvm alias\" lists manual aliases instead of implicit aliases when present" @@ -0,0 +1,49 @@ +#!/bin/sh + +. ../../../nvm.sh + +die () { echo $@ ; cleanup ; exit 1; } +cleanup () { + rm -rf ../../../alias/stable + rm -rf ../../../alias/unstable + rm -rf ../../../alias/node + rm -rf ../../../alias/iojs + rm -rf ../../../v0.8.1 + rm -rf ../../../v0.9.1 + rm -rf ../../../versions/io.js/v0.2.1 +} + +mkdir ../../../v0.8.1 +mkdir ../../../v0.9.1 +mkdir -p ../../../versions/io.js/v0.2.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 node stable +nvm alias iojs unstable + +NVM_ALIAS_OUTPUT=$(nvm alias) + +echo "$NVM_ALIAS_OUTPUT" | command grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \ + || die "nvm alias did not contain the overridden 'stable' alias" + +echo "$NVM_ALIAS_OUTPUT" | command grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \ + || die "nvm alias did not contain the overridden 'unstable' alias" + +echo "$NVM_ALIAS_OUTPUT" | command grep -e "^node -> stable (-> $UNSTABLE_VERSION)$" \ + || die "nvm alias did not contain the overridden 'node' alias" + +echo "$NVM_ALIAS_OUTPUT" | command grep -e "^iojs -> unstable (-> $STABLE_VERSION)$" \ + || die "nvm alias did not contain the overridden 'iojs' alias" + +cleanup + diff --git "a/test/fast/Aliases/Running \"nvm alias\" should list all aliases." "b/test/fast/Aliases/Running \"nvm alias\" should list all aliases." new file mode 100755 index 0000000..1a7cac1 --- /dev/null +++ "b/test/fast/Aliases/Running \"nvm alias\" should list all aliases." @@ -0,0 +1,48 @@ +#!/bin/sh + +. ../../../nvm.sh + +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" + diff --git a/test/fast/Aliases/circular/nvm_resolve_alias b/test/fast/Aliases/circular/nvm_resolve_alias new file mode 100755 index 0000000..4b5dab9 --- /dev/null +++ b/test/fast/Aliases/circular/nvm_resolve_alias @@ -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" + diff --git a/test/fast/Aliases/circular/nvm_resolve_local_alias b/test/fast/Aliases/circular/nvm_resolve_local_alias new file mode 100755 index 0000000..1d25054 --- /dev/null +++ b/test/fast/Aliases/circular/nvm_resolve_local_alias @@ -0,0 +1,36 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../../nvm.sh + +ALIAS="$(nvm_resolve_local_alias loopback)" +[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_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_local_alias one)" +[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_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_local_alias two)" +[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_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_local_alias three)" +[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_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_local_alias four)" +[ "_$ALIAS" = "_∞" ] || die "nvm_resolve_local_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" + diff --git a/test/fast/Aliases/circular/setup b/test/fast/Aliases/circular/setup new file mode 100755 index 0000000..8f2b142 --- /dev/null +++ b/test/fast/Aliases/circular/setup @@ -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 + diff --git a/test/fast/Aliases/circular/teardown b/test/fast/Aliases/circular/teardown new file mode 100755 index 0000000..9b6c79c --- /dev/null +++ b/test/fast/Aliases/circular/teardown @@ -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 + diff --git a/test/fast/Aliases/nvm_ensure_default_set b/test/fast/Aliases/nvm_ensure_default_set new file mode 100755 index 0000000..c719e4b --- /dev/null +++ b/test/fast/Aliases/nvm_ensure_default_set @@ -0,0 +1,18 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm alias default 0.1 >/dev/null || die "'nvm alias default 0.1' failed" + +nvm_ensure_default_set 0.3 || die "'nvm_ensure_default_set' with an existing default alias exits 0" + +nvm unalias default || die "'nvm unalias default' failed" + +OUTPUT="$(nvm_ensure_default_set 0.2)" +EXPECTED_OUTPUT="Creating default alias: default -> 0.2 (-> iojs-v0.2.10)" +EXIT_CODE="$?" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set 0.2' did not output '$EXPECTED_OUTPUT', got '$OUTPUT'" +[ "_$EXIT_CODE" = "_0" ] || die "'nvm_ensure_default_set 0.2' did not exit with 0, got $EXIT_CODE" diff --git a/test/fast/Aliases/nvm_resolve_alias b/test/fast/Aliases/nvm_resolve_alias new file mode 100755 index 0000000..f367eb3 --- /dev/null +++ b/test/fast/Aliases/nvm_resolve_alias @@ -0,0 +1,33 @@ +#!/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" ] || die "'nvm_resolve_alias stable' was not v0.0; got $STABLE" + +NODE="$(nvm_resolve_alias node)" +[ "_$NODE" = "_stable" ] || die "'nvm_resolve_alias node' was not stable; got $NODE" + +UNSTABLE="$(nvm_resolve_alias unstable)" +[ "_$UNSTABLE" = "_v0.1" ] || die "'nvm_resolve_alias unstable' was not v0.1; got $UNSTABLE" + +IOJS="$(nvm_resolve_alias iojs)" +[ "_$IOJS" = "_iojs-v0.2" ] || die "'nvm_resolve_alias iojs' was not iojs-v0.2; got $IOJS" diff --git a/test/fast/Aliases/nvm_resolve_local_alias b/test/fast/Aliases/nvm_resolve_local_alias new file mode 100755 index 0000000..384fece --- /dev/null +++ b/test/fast/Aliases/nvm_resolve_local_alias @@ -0,0 +1,35 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +EXIT_CODE=$(nvm_resolve_local_alias ; echo $?) +[ "_$EXIT_CODE" = "_1" ] || die "nvm_resolve_local_alias without an argument did not return 1; got $EXIT_CODE" + +for i in $(seq 1 10) + do + STABLE_ALIAS="$(nvm_resolve_local_alias test-stable-$i)" + [ "_$STABLE_ALIAS" = "_v0.0.$i" ] \ + || die "'nvm_resolve_local_alias test-stable-$i' was not v0.0.$i; got $STABLE_ALIAS" + UNSTABLE_ALIAS="$(nvm_resolve_local_alias test-unstable-$i)" + [ "_$UNSTABLE_ALIAS" = "_v0.1.$i" ] \ + || die "'nvm_resolve_local_alias test-unstable-$i' was not v0.1.$i; got $UNSTABLE_ALIAS" +done + +OUTPUT="$(nvm_resolve_local_alias nonexistent)" +EXIT_CODE=$(nvm_resolve_local_alias nonexistent > /dev/null 2>&1 ; echo $?) +[ "_$EXIT_CODE" = "_2" ] || die "'nvm_resolve_local_alias nonexistent' did not return 2; got $EXIT_CODE" +[ "_$OUTPUT" = "_" ] || die "'nvm_resolve_local_alias nonexistent' did not have empty output; got $OUTPUT" + +STABLE="$(nvm_resolve_local_alias stable)" +[ "_$STABLE" = "_v0.0.10" ] || die "'nvm_resolve_local_alias stable' was not v0.0.10; got $STABLE" + +NODE="$(nvm_resolve_local_alias node)" +[ "_$NODE" = "_v0.0.10" ] || die "'nvm_resolve_local_alias node' was not v0.0.10; got $NODE" + +UNSTABLE="$(nvm_resolve_local_alias unstable)" +[ "_$UNSTABLE" = "_v0.1.10" ] || die "'nvm_resolve_local_alias unstable' was not v0.1.10; got $UNSTABLE" + +IOJS="$(nvm_resolve_local_alias iojs)" +[ "_$IOJS" = "_iojs-v0.2.10" ] || die "'nvm_resolve_local_alias iojs' was not iojs-v0.2.10; got $IOJS" diff --git a/test/fast/Aliases/setup b/test/fast/Aliases/setup new file mode 100755 index 0000000..a28a5c2 --- /dev/null +++ b/test/fast/Aliases/setup @@ -0,0 +1,11 @@ +#!/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 + echo 0.2.$i > ../../../alias/test-iojs-$i + mkdir -p ../../../versions/io.js/v0.2.$i +done diff --git a/test/fast/Aliases/teardown b/test/fast/Aliases/teardown new file mode 100755 index 0000000..005c729 --- /dev/null +++ b/test/fast/Aliases/teardown @@ -0,0 +1,17 @@ +#!/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" + rm -rf "../../../alias/test-iojs-$i" + rm -rf "../../../versions/io.js/v0.2.$i" +done + +rm -f "../../../alias/stable" +rm -f "../../../alias/unstable" +rm -f "../../../alias/node" +rm -f "../../../alias/iojs" +rm -f "../../../alias/default" diff --git "a/test/fast/Listing paths/Running \"nvm which 0.0.2\" should display only version 0.0.2." "b/test/fast/Listing paths/Running \"nvm which 0.0.2\" should display only version 0.0.2." new file mode 100755 index 0000000..333782e --- /dev/null +++ "b/test/fast/Listing paths/Running \"nvm which 0.0.2\" should display only version 0.0.2." @@ -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'" + diff --git "a/test/fast/Listing paths/Running \"nvm which foo\" should return a nonzero exit code when not found" "b/test/fast/Listing paths/Running \"nvm which foo\" should return a nonzero exit code when not found" new file mode 100755 index 0000000..4c4a301 --- /dev/null +++ "b/test/fast/Listing paths/Running \"nvm which foo\" should return a nonzero exit code when not found" @@ -0,0 +1,6 @@ + #!/bin/sh + +. ../../../nvm.sh + +nvm which nonexistent_version +[ "_$?" = "_1" ] diff --git a/test/fast/Listing paths/teardown b/test/fast/Listing paths/teardown new file mode 100755 index 0000000..25277fe --- /dev/null +++ b/test/fast/Listing paths/teardown @@ -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 diff --git "a/test/fast/Listing versions/Running \"nvm ls 0.0.2\" should display only version 0.0.2." "b/test/fast/Listing versions/Running \"nvm ls 0.0.2\" should display only version 0.0.2." new file mode 100755 index 0000000..c2b7a63 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls 0.0.2\" should display only version 0.0.2." @@ -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 + diff --git "a/test/fast/Listing versions/Running \"nvm ls 0.2\" should display only 0.2.x versions." "b/test/fast/Listing versions/Running \"nvm ls 0.2\" should display only 0.2.x versions." new file mode 100755 index 0000000..8889f09 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls 0.2\" should display only 0.2.x versions." @@ -0,0 +1,41 @@ +#!/bin/sh + +mkdir ../../../v0.1.3 +mkdir ../../../v0.2.3 +mkdir ../../../v0.20.3 + +. ../../../nvm.sh + +die () { echo $@ ; exit 1; } + +# The result should contain only the appropriate version numbers. + +nvm ls 0.1 | grep 'v0.2.3' > /dev/null +if [ $? -eq 0 ]; then + 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 diff --git "a/test/fast/Listing versions/Running \"nvm ls foo\" should return a nonzero exit code when not found" "b/test/fast/Listing versions/Running \"nvm ls foo\" should return a nonzero exit code when not found" new file mode 100755 index 0000000..d3f6974 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls foo\" should return a nonzero exit code when not found" @@ -0,0 +1,7 @@ + #!/bin/sh + +. ../../../nvm.sh + +nvm ls nonexistent_version +[ "$?" = "3" ] + diff --git "a/test/fast/Listing versions/Running \"nvm ls io\" should return NA" "b/test/fast/Listing versions/Running \"nvm ls io\" should return NA" new file mode 100755 index 0000000..ddd1123 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls io\" should return NA" @@ -0,0 +1,7 @@ + #!/bin/sh + +. ../../../nvm.sh + +nvm ls io +[ "$?" = "3" ] + diff --git "a/test/fast/Listing versions/Running \"nvm ls node_\" should return a nonzero exit code when not found" "b/test/fast/Listing versions/Running \"nvm ls node_\" should return a nonzero exit code when not found" new file mode 100755 index 0000000..2d6b012 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls node_\" should return a nonzero exit code when not found" @@ -0,0 +1,7 @@ + #!/bin/sh + +. ../../../nvm.sh + +nvm ls node_ +[ "$?" = "3" ] + diff --git "a/test/fast/Listing versions/Running \"nvm ls stable\" and \"nvm ls unstable\" should return the appropriate implicit alias" "b/test/fast/Listing versions/Running \"nvm ls stable\" and \"nvm ls unstable\" should return the appropriate implicit alias" new file mode 100755 index 0000000..a5ab151 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls stable\" and \"nvm ls unstable\" should return the appropriate implicit alias" @@ -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" + diff --git "a/test/fast/Listing versions/Running \"nvm ls system\" should include \"system\" when appropriate" "b/test/fast/Listing versions/Running \"nvm ls system\" should include \"system\" when appropriate" new file mode 100755 index 0000000..f1e5ef6 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls system\" should include \"system\" when appropriate" @@ -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' + diff --git "a/test/fast/Listing versions/Running \"nvm ls\" should display all installed versions." "b/test/fast/Listing versions/Running \"nvm ls\" should display all installed versions." new file mode 100755 index 0000000..e7cc3f7 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" should display all installed versions." @@ -0,0 +1,24 @@ +#!/bin/sh + +. ../../../nvm.sh + +mkdir ../../../v0.0.1 +mkdir ../../../v0.0.3 +mkdir ../../../v0.0.9 +mkdir ../../../v0.3.1 +mkdir ../../../v0.3.3 +mkdir ../../../v0.3.9 +mkdir -p ../../../versions/node/v0.12.87 +mkdir -p ../../../versions/node/v0.12.9 +mkdir -p ../../../versions/io.js/v0.1.2 +mkdir -p ../../../versions/io.js/v0.10.2 + +# The result should contain the version numbers. +nvm ls | grep v0.0.1 >/dev/null && +nvm ls | grep v0.0.3 >/dev/null && +nvm ls | grep v0.0.9 >/dev/null && +nvm ls | grep v0.3.1 >/dev/null && +nvm ls | grep v0.3.3 >/dev/null && +nvm ls | grep v0.3.9 >/dev/null && +nvm ls | grep v0.12.87 >/dev/null && +nvm ls | grep iojs-v0.1.2 >/dev/null diff --git "a/test/fast/Listing versions/Running \"nvm ls\" should filter out \".nvm\"" "b/test/fast/Listing versions/Running \"nvm ls\" should filter out \".nvm\"" new file mode 100755 index 0000000..d01aa7a --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" should filter out \".nvm\"" @@ -0,0 +1,9 @@ +#!/bin/sh + +mkdir ../../../v0.1.3 +mkdir ../../../v0.2.3 + +. ../../../nvm.sh + +[ -z `nvm ls | grep '^ *\.'` ] +# The result should contain only the appropriate version numbers. diff --git "a/test/fast/Listing versions/Running \"nvm ls\" should filter out \"versions\"" "b/test/fast/Listing versions/Running \"nvm ls\" should filter out \"versions\"" new file mode 100755 index 0000000..c4d61bd --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" should filter out \"versions\"" @@ -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. + diff --git "a/test/fast/Listing versions/Running \"nvm ls\" should include \"system\" when appropriate" "b/test/fast/Listing versions/Running \"nvm ls\" should include \"system\" when appropriate" new file mode 100755 index 0000000..9afd40a --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" should include \"system\" when appropriate" @@ -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' + diff --git "a/test/fast/Listing versions/Running \"nvm ls\" should list versions in the \"versions\" directory" "b/test/fast/Listing versions/Running \"nvm ls\" should list versions in the \"versions\" directory" new file mode 100755 index 0000000..8368b1e --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" should list versions in the \"versions\" directory" @@ -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' + diff --git "a/test/fast/Listing versions/Running \"nvm ls\" with node-like versioning vx.x.x should only list a matched version" "b/test/fast/Listing versions/Running \"nvm ls\" with node-like versioning vx.x.x should only list a matched version" new file mode 100755 index 0000000..43c77d8 --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" with node-like versioning vx.x.x should only list a matched version" @@ -0,0 +1,11 @@ +#!/bin/sh + +mkdir ../../../v0.1.2 + +. ../../../nvm.sh + +nvm ls v0.1 | grep v0.1.2 && +nvm ls v0.1.2 | grep v0.1.2 && +nvm ls v0.1. | grep v0.1.2 && +nvm ls v0.1.1 | grep N/A + diff --git a/test/fast/Listing versions/teardown b/test/fast/Listing versions/teardown new file mode 100755 index 0000000..25669ea --- /dev/null +++ b/test/fast/Listing versions/teardown @@ -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 + diff --git "a/test/fast/Running \"nvm alias\" should create a file in the alias directory." "b/test/fast/Running \"nvm alias\" should create a file in the alias directory." new file mode 100755 index 0000000..38ba260 --- /dev/null +++ "b/test/fast/Running \"nvm alias\" should create a file in the alias directory." @@ -0,0 +1,5 @@ +#!/bin/sh + +. ../../nvm.sh +nvm alias test v0.1.2 +[ "$(cat ../../alias/test)" = "v0.1.2" ] diff --git "a/test/fast/Running \"nvm current\" should display current nvm environment." "b/test/fast/Running \"nvm current\" should display current nvm environment." new file mode 100755 index 0000000..5748fd6 --- /dev/null +++ "b/test/fast/Running \"nvm current\" should display current nvm environment." @@ -0,0 +1,10 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../nvm.sh + +nvm deactivate 2>&1 + +[ "$(nvm current)" = "system" ] || [ "$(nvm current)" = "none" ] || die '"nvm current" did not report "system" or "none" when deactivated' + diff --git "a/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." "b/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." new file mode 100755 index 0000000..0ce98b6 --- /dev/null +++ "b/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." @@ -0,0 +1,17 @@ +#!/bin/sh + +mkdir -p ../../v0.2.3 + +die () { echo $@ ; exit 1; } + +[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2 + +. ../../nvm.sh +nvm use --delete-prefix v0.2.3 || 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 || 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" diff --git "a/test/fast/Running \"nvm install\" with \"--reinstall-packages-from\" requires a valid version" "b/test/fast/Running \"nvm install\" with \"--reinstall-packages-from\" requires a valid version" new file mode 100755 index 0000000..00b6bc6 --- /dev/null +++ "b/test/fast/Running \"nvm install\" with \"--reinstall-packages-from\" requires a valid version" @@ -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" + diff --git "a/test/fast/Running \"nvm install\" with an invalid version fails nicely" "b/test/fast/Running \"nvm install\" with an invalid version fails nicely" new file mode 100755 index 0000000..d113890 --- /dev/null +++ "b/test/fast/Running \"nvm install\" with an invalid version fails nicely" @@ -0,0 +1,7 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../nvm.sh +[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message" + diff --git "a/test/fast/Running \"nvm unalias\" should remove the alias file." "b/test/fast/Running \"nvm unalias\" should remove the alias file." new file mode 100755 index 0000000..f8ed49d --- /dev/null +++ "b/test/fast/Running \"nvm unalias\" should remove the alias file." @@ -0,0 +1,6 @@ +#!/bin/sh + +echo v0.1.2 > ../../alias/test +. ../../nvm.sh +nvm unalias test +! [ -e ../../alias/test ] diff --git "a/test/fast/Running \"nvm uninstall\" should remove the appropriate directory." "b/test/fast/Running \"nvm uninstall\" should remove the appropriate directory." new file mode 100755 index 0000000..ba1ddbb --- /dev/null +++ "b/test/fast/Running \"nvm uninstall\" should remove the appropriate directory." @@ -0,0 +1,10 @@ +#!/bin/sh + +cd ../.. +mkdir v0.0.1 +mkdir src/node-v0.0.1 + +. ./nvm.sh +nvm uninstall v0.0.1 + +[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1' ] diff --git "a/test/fast/Running \"nvm unload\" should unset all function and variables." "b/test/fast/Running \"nvm unload\" should unset all function and variables." new file mode 100755 index 0000000..0f4c50e --- /dev/null +++ "b/test/fast/Running \"nvm unload\" should unset all function and variables." @@ -0,0 +1,12 @@ +#!/bin/sh + +fail () { echo $@ ; exit 1; } + +. ../../nvm.sh + +type nvm > /dev/null 2>&1 || fail "NVM not loaded" + +nvm unload + +type nvm > /dev/null 2>&1 && fail "NVM not unloaded" || exit 0 + diff --git "a/test/fast/Running \"nvm use foo\" where \"foo\" is circular aborts" "b/test/fast/Running \"nvm use foo\" where \"foo\" is circular aborts" new file mode 100755 index 0000000..97c45eb --- /dev/null +++ "b/test/fast/Running \"nvm use foo\" where \"foo\" is circular aborts" @@ -0,0 +1,30 @@ +#!/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" + +OUTPUT="$(nvm use --silent foo 2>&1)" +EXPECTED_OUTPUT='' +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" + +EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)" +[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE" + +cleanup; + diff --git "a/test/fast/Running \"nvm use iojs\" uses latest io.js version" "b/test/fast/Running \"nvm use iojs\" uses latest io.js version" new file mode 100755 index 0000000..edee505 --- /dev/null +++ "b/test/fast/Running \"nvm use iojs\" uses latest io.js version" @@ -0,0 +1,38 @@ +#!/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" + +OUTPUT="$(nvm use --silent foo 2>&1)" +EXPECTED_OUTPUT='' +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" + +OUTPUT="$(nvm use foo --silent 2>&1)" +EXPECTED_OUTPUT='' +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use foo --silent' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" + +EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)" +[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE" + +EXIT_CODE="$(nvm use foo --silent 2>/dev/null ; echo $?)" +[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use foo --silent'; got $EXIT_CODE" + +cleanup; + diff --git "a/test/fast/Running \"nvm use system\" should work as expected" "b/test/fast/Running \"nvm use system\" should work as expected" new file mode 100755 index 0000000..4eb3319 --- /dev/null +++ "b/test/fast/Running \"nvm use system\" should work as expected" @@ -0,0 +1,22 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../nvm.sh + +nvm_has_system_node() { return 0; } +nvm_print_npm_version() { return ' (npm v1.2.3)'; } +EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)" +[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node" +EXPECTED_OUTPUT="" +[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node or --silent was not silent" + +nvm_has_system_node() { return 1; } +nvm_print_npm_version() { return ''; } +EXPECTED_OUTPUT="System version of node not found." +[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || 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" +EXPECTED_OUTPUT="" +[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found or --silent was not silent" +nvm use --silent system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found or --silent was not silent" + diff --git "a/test/fast/Running \"nvm use x\" should create and change the \"current\" symlink" "b/test/fast/Running \"nvm use x\" should create and change the \"current\" symlink" new file mode 100755 index 0000000..d5fda3c --- /dev/null +++ "b/test/fast/Running \"nvm use x\" should create and change the \"current\" symlink" @@ -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 diff --git "a/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" "b/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" new file mode 100755 index 0000000..4ac8b4b --- /dev/null +++ "b/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" @@ -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 + diff --git a/test/fast/Sourcing nvm.sh should make the nvm command available. b/test/fast/Sourcing nvm.sh should make the nvm command available. new file mode 100755 index 0000000..24f8efa --- /dev/null +++ b/test/fast/Sourcing nvm.sh should make the nvm command available. @@ -0,0 +1,4 @@ +#!/bin/sh + +. ../../nvm.sh +nvm diff --git a/test/fast/Unit tests/iojs.org-dist-index.tab b/test/fast/Unit tests/iojs.org-dist-index.tab new file mode 100644 index 0000000..8589bb9 --- /dev/null +++ b/test/fast/Unit tests/iojs.org-dist-index.tab @@ -0,0 +1,42 @@ +version date files npm v8 uv zlib openssl modules +v3.3.1 2015-09-15 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.14.3 4.4.63.30 1.7.4 1.2.8 1.0.2d 45 +v3.3.0 2015-09-02 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.13.3 4.4.63.30 1.7.3 1.2.8 1.0.2d 45 +v3.2.0 2015-08-25 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.13.3 4.4.63.26 1.6.1 1.2.8 1.0.2d 45 +v3.1.0 2015-08-19 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.13.3 4.4.63.26 1.6.1 1.2.8 1.0.2d 45 +v3.0.0 2015-08-04 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.13.3 4.4.63.26 1.6.1 1.2.8 1.0.2d 45 +v2.5.0 2015-07-28 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.13.2 4.2.77.21 1.6.1 1.2.8 1.0.2d 44 +v2.4.0 2015-07-17 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.13.0 4.2.77.20 1.6.1 1.2.8 1.0.2d 44 +v2.3.4 2015-07-12 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.12.1 4.2.77.20 1.6.1 1.2.8 1.0.2d 44 +v2.3.3 2015-07-04 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.11.3 4.2.77.20 1.6.1 1.2.8 1.0.2c 44 +v2.3.2 2015-07-02 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.11.3 4.2.77.20 1.6.1 1.2.8 1.0.2c 44 +v2.3.1 2015-06-23 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.11.3 4.2.77.20 1.6.1 1.2.8 1.0.2c 44 +v2.3.0 2015-06-13 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.11.1 4.2.77.20 1.6.1 1.2.8 1.0.2c 44 +v2.2.1 2015-06-01 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.11.0 4.2.77.20 1.5.0 1.2.8 1.0.2a 44 +v2.2.0 2015-06-01 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.11.0 4.2.77.20 1.5.0 1.2.8 1.0.2a 44 +v2.1.0 2015-05-24 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.10.1 4.2.77.20 1.5.0 1.2.8 1.0.2a 44 +v2.0.2 2015-05-15 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.9.0 4.2.77.20 1.5.0 1.2.8 1.0.2a 44 +v2.0.1 2015-05-08 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.9.0 4.2.77.20 1.5.0 1.2.8 1.0.2a 44 +v2.0.0 2015-05-04 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.9.0 4.2.77.18 1.4.2 1.2.8 1.0.2a 44 +v1.8.4 2015-07-12 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.9.0 4.1.0.27 1.4.2 1.2.8 1.0.2d 43 +v1.8.3 2015-07-04 headers,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.9.0 4.1.0.27 1.4.2 1.2.8 1.0.2c 43 +v1.8.2 2015-05-18 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.9.0 4.1.0.27 1.4.2 1.2.8 1.0.2a 43 +v1.8.1 2015-04-21 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.8.3 4.1.0.27 1.4.2 1.2.8 1.0.2a 43 +v1.7.1 2015-04-17 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.7.6 4.1.0.27 1.4.2 1.2.8 1.0.1m 43 +v1.6.4 2015-04-06 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.7.5 4.1.0.27 1.4.2 1.2.8 1.0.1m 43 +v1.6.3 2015-03-31 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.7.4 4.1.0.27 1.4.2 1.2.8 1.0.1m 43 +v1.6.2 2015-03-23 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.7.1 4.1.0.25 1.4.2 1.2.8 1.0.1m 43 +v1.6.1 2015-03-20 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.7.1 4.1.0.21 1.4.2 1.2.8 1.0.1m 43 +v1.6.0 2015-03-20 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.7.1 4.1.0.21 1.4.2 1.2.8 1.0.1m 43 +v1.5.1 2015-03-09 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.7.0 4.1.0.21 1.4.2 1.2.8 1.0.1k 43 +v1.5.0 2015-03-06 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.7.0 4.1.0.21 1.4.2 1.2.8 1.0.1k 43 +v1.4.3 2015-03-03 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.6.1 4.1.0.21 1.4.2 1.2.8 1.0.1k 43 +v1.4.2 2015-02-28 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.6.1 4.1.0.21 1.4.2 1.2.8 1.0.1k 43 +v1.4.1 2015-02-27 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.6.0 4.1.0.21 1.4.2 1.2.8 1.0.1k 43 +v1.3.0 2015-02-20 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.5.1 4.1.0.14 1.4.0 1.2.8 1.0.1k 43 +v1.2.0 2015-02-11 linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.5.1 4.1.0.14 1.4.0 1.2.8 1.0.1k 43 +v1.1.0 2015-02-03 linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.4.1 4.1.0.14 1.3.0 1.2.8 1.0.1k 43 +v1.0.4 2015-01-24 linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.3.0 4.1.0.12 1.2.1 1.2.8 1.0.1k 42 +v1.0.3 2015-01-20 linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.2.0 4.1.0.7 1.2.1 1.2.8 1.0.1k 42 +v1.0.2 2015-01-16 linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.1.18 3.31.74.1 1.2.1 1.2.8 1.0.1k 42 +v1.0.1 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.1.18 3.31.74.1 1.2.0 1.2.8 1.0.1k 42 +v1.0.0 2015-01-14 linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 2.1.18 3.31.74.1 1.2.0 1.2.8 1.0.1k 42 diff --git a/test/fast/Unit tests/iojs_version_has_solaris_binary b/test/fast/Unit tests/iojs_version_has_solaris_binary new file mode 100755 index 0000000..7a797cb --- /dev/null +++ b/test/fast/Unit tests/iojs_version_has_solaris_binary @@ -0,0 +1,17 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh +. ../../common.sh + +assert_not_ok iojs_version_has_solaris_binary "" +assert_not_ok iojs_version_has_solaris_binary "foo" +assert_not_ok iojs_version_has_solaris_binary "v1.1.0" + +assert_ok iojs_version_has_solaris_binary "v3.3.1" +assert_ok iojs_version_has_solaris_binary "iojs-v3.3.1" +assert_ok iojs_version_has_solaris_binary "v3.3.2" +assert_ok iojs_version_has_solaris_binary "iojs-v3.3.2" +assert_ok iojs_version_has_solaris_binary "v3.4.1" +assert_ok iojs_version_has_solaris_binary "iojs-v3.4.1" diff --git a/test/fast/Unit tests/node_version_has_solaris_binary b/test/fast/Unit tests/node_version_has_solaris_binary new file mode 100755 index 0000000..db62d59 --- /dev/null +++ b/test/fast/Unit tests/node_version_has_solaris_binary @@ -0,0 +1,33 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh +. ../../common.sh + +# Invalid version numbers fail +assert_not_ok node_version_has_solaris_binary "" +assert_not_ok node_version_has_solaris_binary "foo" + +# "Invalid" node version numbers fail +assert_not_ok node_version_has_solaris_binary "v1.0.0" +assert_not_ok node_version_has_solaris_binary "v3.3.1" + +# Valid io.js version numbers that have a Solaris binary fail +assert_not_ok node_version_has_solaris_binary "iojs-v3.3.1" + +# Invvalid io.js version numbers fail +assert_not_ok node_version_has_solaris_binary "iojs-v0.12.7" + +# Valid node version numbers that don't have a Solaris binary fail +assert_not_ok node_version_has_solaris_binary "v0.8.5" + +# Valid node version numbers that have a Solaris binary succeed +assert_ok node_version_has_solaris_binary "v0.8.6" +assert_ok node_version_has_solaris_binary "v0.10.0" +assert_ok node_version_has_solaris_binary "v0.12.7" + +# Valid "merged" version numbers fail, because they're not +# considered node version numbers +assert_not_ok node_version_has_solaris_binary "v4.0.0" +assert_not_ok node_version_has_solaris_binary "v4.1.1" diff --git a/test/fast/Unit tests/nodejs.org-dist-index.tab b/test/fast/Unit tests/nodejs.org-dist-index.tab new file mode 100644 index 0000000..030ddb9 --- /dev/null +++ b/test/fast/Unit tests/nodejs.org-dist-index.tab @@ -0,0 +1,235 @@ +version date files npm v8 uv zlib openssl modules lts +v5.3.0 2015-12-15 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 3.3.12 4.6.85.31 1.8.0 1.2.8 1.0.2e 47 - +v5.2.0 2015-12-09 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 3.3.12 4.6.85.31 1.7.5 1.2.8 1.0.2e 47 - +v5.1.1 2015-12-03 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 3.3.12 4.6.85.31 1.7.5 1.2.8 1.0.2e 47 - +v5.1.0 2015-11-17 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 3.3.12 4.6.85.31 1.7.5 1.2.8 1.0.2d 47 - +v5.0.0 2015-10-29 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 3.3.6 4.6.85.28 1.7.5 1.2.8 1.0.2d 47 - +v4.2.3 2015-12-03 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 2.14.7 4.5.103.35 1.7.5 1.2.8 1.0.2e 46 Argon +v4.2.2 2015-11-03 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 2.14.7 4.5.103.35 1.7.5 1.2.8 1.0.2d 46 Argon +v4.2.1 2015-10-13 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 2.14.7 4.5.103.35 1.7.5 1.2.8 1.0.2d 46 Argon +v4.2.0 2015-10-12 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 2.14.7 4.5.103.35 1.7.5 1.2.8 1.0.2d 46 Argon +v4.1.2 2015-10-05 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 2.14.4 4.5.103.35 1.7.5 1.2.8 1.0.2d 46 - +v4.1.1 2015-09-23 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 2.14.4 4.5.103.33 1.7.4 1.2.8 1.0.2d 46 - +v4.1.0 2015-09-18 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 2.14.3 4.5.103.33 1.7.4 1.2.8 1.0.2d 46 - +v4.0.0 2015-09-08 headers,linux-arm64,linux-armv6l,linux-armv7l,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,src,sunos-x64,sunos-x86,win-x64-msi,win-x86-msi 2.14.2 4.5.103.30 1.7.3 1.2.8 1.0.2d 46 - +v0.12.9 2015-12-03 headers,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.14.9 3.28.71.19 1.6.1 1.2.8 1.0.1p 14 - +v0.12.8 2015-11-24 headers,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.14.9 3.28.71.19 1.6.1 1.2.8 1.0.1p 14 - +v0.12.7 2015-07-09 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.11.3 3.28.71.19 1.6.1 1.2.8 1.0.1p 14 - +v0.12.6 2015-07-04 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.11.2 3.28.71.19 1.6.1 1.2.8 1.0.1o 14 - +v0.12.5 2015-06-22 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.11.2 3.28.71.19 1.6.1 1.2.8 1.0.1o 14 - +v0.12.4 2015-05-23 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.10.1 3.28.71.19 1.5.0 1.2.8 1.0.1m 14 - +v0.12.3 2015-05-14 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.9.1 3.28.71.19 1.5.0 1.2.8 1.0.1m 14 - +v0.12.2 2015-03-31 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.7.4 3.28.73.0 1.4.2 1.2.8 1.0.1m 14 - +v0.12.1 2015-03-24 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.5.1 3.28.73.0 1.0.2 1.2.8 1.0.1m 14 - +v0.12.0 2015-02-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.5.1 3.28.73.0 1.0.2 1.2.8 1.0.1l 14 - +v0.11.16 2015-01-30 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.3.0 3.28.73.0 1.0.2 1.2.8 1.0.1l 14 - +v0.11.15 2015-01-20 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.1.6 3.28.73.0 1.0.2 1.2.8 1.0.1j 14 - +v0.11.14 2015-01-16 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 2.0.0 3.26.33.0 1.0.0 1.2.3 1.0.1i 14 - +v0.11.13 2014-05-02 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.9 3.25.30.0 0.11.25 1.2.3 1.0.1g 14 - +v0.11.12 2014-04-11 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.3 3.22.24.19 0.11.22 1.2.3 1.0.1f 14 - +v0.11.11 2014-04-11 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.25 3.22.24.19 0.11.18 1.2.3 1.0.1f 14 - +v0.11.10 2014-04-11 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.22 3.22.24.10 0.11.17 1.2.3 1.0.1e 13 - +v0.11.9 2013-12-02 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.15 3.22.24.5 0.11.15 1.2.3 1.0.1e 13 - +v0.11.8 2013-12-02 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.13 3.21.18.3 0.11.14 1.2.3 1.0.1e 13 - +v0.11.7 2013-10-09 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.8 3.20.17.0 0.11.13 1.2.3 1.0.1e 0x000C - +v0.11.6 2013-08-22 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x86-msi 1.3.8 3.20.14.1 0.11.8 1.2.3 1.0.1e 0x000C - +v0.11.5 2013-08-12 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.6 3.20.11.0 0.11.7 1.2.3 1.0.1e 0x000C - +v0.11.4 2013-07-12 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x86-msi 1.3.4 3.20.2.0 0.11.5 1.2.3 1.0.1e 0x000C - +v0.11.3 2013-06-26 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.25 3.19.13.0 0.11.5 1.2.3 1.0.1e 0x000C - +v0.11.2 2013-05-13 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.21 3.19.0.0 0.11.2 1.2.3 1.0.1e 0x000C - +v0.11.1 2013-04-19 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.18 3.18.0.0 0.11.1 1.2.3 1.0.1e 0x000C - +v0.11.0 2013-04-01 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.15 3.17.13.0 0.10.3 1.2.3 1.0.1e 0x000C - +v0.10.41 2015-12-03 headers,linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.29 3.14.5.9 0.10.36 1.2.8 1.0.1p 11 - +v0.10.40 2015-07-09 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.36 1.2.8 1.0.1p 11 - +v0.10.39 2015-06-19 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.36 1.2.8 1.0.1o 11 - +v0.10.38 2015-03-23 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.36 1.2.8 1.0.1m 11 - +v0.10.37 2015-03-12 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.36 1.2.8 1.0.1l 11 - +v0.10.36 2015-01-30 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.30 1.2.8 1.0.1l 11 - +v0.10.35 2014-12-22 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.30 1.2.8 1.0.1j 11 - +v0.10.34 2014-12-17 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.30 1.2.8 1.0.1j 11 - +v0.10.33 2014-10-21 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.29 1.2.3 1.0.1j 11 - +v0.10.32 2014-09-16 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.28 3.14.5.9 0.10.28 1.2.3 1.0.1i 11 - +v0.10.31 2014-08-19 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.23 3.14.5.9 0.10.28 1.2.3 1.0.1i 11 - +v0.10.30 2014-07-31 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.21 3.14.5.9 0.10.28 1.2.3 1.0.1h 11 - +v0.10.29 2014-06-09 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.14 3.14.5.9 0.10.27 1.2.3 1.0.1h 11 - +v0.10.28 2014-06-13 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.9 3.14.5.9 0.10.27 1.2.3 1.0.1g 11 - +v0.10.27 2014-08-07 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.8 3.14.5.9 0.10.27 1.2.3 1.0.1g 11 - +v0.10.26 2014-04-11 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.4.3 3.14.5.9 0.10.25 1.2.3 1.0.1e 11 - +v0.10.25 2014-04-11 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.24 3.14.5.9 0.10.23 1.2.3 1.0.1e 11 - +v0.10.24 2013-12-19 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.21 3.14.5.9 0.10.21 1.2.3 1.0.1e 11 - +v0.10.23 2013-12-12 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.17 3.14.5.9 0.10.20 1.2.3 1.0.1e 11 - +v0.10.22 2013-12-02 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.14 3.14.5.9 0.10.19 1.2.3 1.0.1e 11 - +v0.10.21 2013-10-18 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.11 3.14.5.9 0.10.18 1.2.3 1.0.1e 11 - +v0.10.20 2013-09-30 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.11 3.14.5.9 0.10.17 1.2.3 1.0.1e 11 - +v0.10.19 2013-09-26 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.11 3.14.5.9 0.10.17 1.2.3 1.0.1e 11 - +v0.10.18 2013-10-09 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.8 3.14.5.9 0.10.15 1.2.3 1.0.1e 11 - +v0.10.17 2013-08-25 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.8 3.14.5.9 0.10.14 1.2.3 1.0.1e 11 - +v0.10.16 2013-08-16 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.8 3.14.5.9 0.10.13 1.2.3 1.0.1e 11 - +v0.10.15 2013-08-12 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.5 3.14.5.9 0.10.13 1.2.3 1.0.1e 11 - +v0.10.14 2013-08-12 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.5 3.14.5.9 0.10.13 1.2.3 1.0.1e 11 - +v0.10.13 2013-07-13 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.3.2 3.14.5.9 0.10.12 1.2.3 1.0.1e 11 - +v0.10.12 2013-06-18 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.32 3.14.5.9 0.10.11 1.2.3 1.0.1e 11 - +v0.10.11 2013-06-13 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.30 3.14.5.9 0.10.11 1.2.3 1.0.1e 11 - +v0.10.10 2013-06-04 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.25 3.14.5.9 0.10.10 1.2.3 1.0.1e 11 - +v0.10.9 2013-06-02 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.24 3.14.5.9 0.10.9 1.2.3 1.0.1e 11 - +v0.10.8 2013-05-24 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.23 3.14.5.9 0.10.8 1.2.3 1.0.1e 11 - +v0.10.7 2013-05-17 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.21 3.14.5.8 0.10.7 1.2.3 1.0.1e 11 - +v0.10.6 2013-05-14 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.18 3.14.5.8 0.10.5 1.2.3 1.0.1e 11 - +v0.10.5 2013-04-26 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.18 3.14.5.8 0.10.5 1.2.3 1.0.1e 11 - +v0.10.4 2013-04-26 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.18 3.14.5.8 0.10.4 1.2.3 1.0.1e 11 - +v0.10.3 2013-04-26 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.17 3.14.5.8 0.10.3 1.2.3 1.0.1e 0x000B - +v0.10.2 2013-03-28 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.15 3.14.5.8 0.10.3 1.2.3 1.0.1e 0x000B - +v0.10.1 2013-03-21 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.15 3.14.5.8 0.10 1.2.3 1.0.1e 0x000B - +v0.10.0 2013-03-11 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.14 3.14.5.8 0.9 1.2.3 1.0.1e 0x000B - +v0.9.12 2013-03-07 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.12 3.14.5.8 0.9 1.2.3 1.0.1e 0x000B - +v0.9.11 2013-03-01 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.12 3.14.5.0 0.9 1.2.3 1.0.1e 0x000B - +v0.9.10 2013-02-25 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.12 3.15.11.15 0.9 1.2.3 1.0.1c 0x000B - +v0.9.9 2013-02-07 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.10 3.15.11.10 0.9 1.2.3 1.0.1c 0x000B - +v0.9.8 2013-02-02 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.3 3.15.11.10 0.9 1.2.3 1.0.1c 0x000A - +v0.9.7 2013-01-18 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.2 3.15.11.7 0.9 1.2.3 1.0.1c 0x000A - +v0.9.6 2013-01-11 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.0 3.15.11.5 0.9 1.2.3 1.0.1c 0x000A - +v0.9.5 2012-12-30 linux-x64,linux-x86,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.70 3.13.7.4 0.9 1.2.3 1.0.1c 0x000A - +v0.9.4 2012-12-21 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.70 3.13.7.4 0.9 1.2.3 1.0.1c 0x000A - +v0.9.3 2015-10-14 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.64 3.13.7.4 0.9 1.2.3 1.0.1c 0x000A - +v0.9.2 2012-09-17 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.61 3.11.10.22 0.9 1.2.3 1.0.1c 0x000A - +v0.9.1 2012-09-13 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.59 3.11.10.19 0.9 1.2.3 1.0.0f 0x000A - +v0.9.0 2012-07-20 osx-x64-pkg,src,win-x64-exe,win-x86-exe,win-x86-msi 1.1.44 3.11.10.15 0.9 1.2.3 1.0.0f 1 - +v0.8.28 2014-07-31 linux-x64,linux-x86,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.30 3.11.10.26 0.8 1.2.3 1.0.0f 1 - +v0.8.27 2014-06-09 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x86-msi 1.2.30 3.11.10.26 0.8 1.2.3 1.0.0f 1 - +v0.8.26 2013-10-18 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.30 3.11.10.26 0.8 1.2.3 1.0.0f 1 - +v0.8.25 2013-06-13 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.30 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.24 2013-06-03 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.24 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.23 2013-04-09 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.18 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.22 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.14 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.21 2013-02-25 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.11 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.20 2013-02-15 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.11 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.19 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.10 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.18 2013-01-18 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.2 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.17 2013-01-13 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.2.0 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.16 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.69 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.15 2012-11-26 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.66 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.14 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.65 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.13 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.65 3.11.10.25 0.8 1.2.3 1.0.0f 1 - +v0.8.12 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.63 3.11.10.22 0.8 1.2.3 1.0.0f 1 - +v0.8.11 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.62 3.11.10.22 0.8 1.2.3 1.0.0f 1 - +v0.8.10 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.62 3.11.10.22 0.8 1.2.3 1.0.0f 1 - +v0.8.9 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.61 3.11.10.22 0.8 1.2.3 1.0.0f 1 - +v0.8.8 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 1.1.59 3.11.10.19 0.8 1.2.3 1.0.0f 1 - +v0.8.7 2015-09-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.49 3.11.10.17 0.8 1.2.3 1.0.0f 1 - +v0.8.6 2012-08-06 linux-x64,linux-x86,osx-x64-pkg,osx-x64-tar,osx-x86-tar,src,sunos-x64,sunos-x86,win-x64-exe,win-x86-exe,win-x86-msi 1.1.48 3.11.10.17 0.8 1.2.3 1.0.0f 1 - +v0.8.5 2015-09-06 osx-x64-pkg,src,win-x64-exe,win-x86-exe,win-x86-msi 1.1.46 3.11.10.17 0.8 1.2.3 1.0.0f 1 - +v0.8.4 2015-09-06 osx-x64-pkg,src,win-x64-exe,win-x86-exe,win-x86-msi 1.1.45 3.11.10.17 0.8 1.2.3 1.0.0f 1 - +v0.8.3 2015-09-06 osx-x64-pkg,src,win-x64-exe,win-x86-exe,win-x86-msi 1.1.43 3.11.10.15 0.8 1.2.3 1.0.0f 1 - +v0.8.2 2012-07-09 osx-x64-pkg,src,win-x64-exe,win-x86-exe,win-x86-msi 1.1.36 3.11.10.14 0.8 1.2.3 1.0.0f 1 - +v0.8.1 2012-06-29 osx-x64-pkg,src,win-x64-exe,win-x86-exe,win-x86-msi 1.1.33 3.11.10.12 0.8 1.2.3 1.0.0f 1 - +v0.8.0 2012-06-22 osx-x64-pkg,src,win-x64-exe,win-x86-exe,win-x86-msi 1.1.32 3.11.10.10 0.8 1.2.3 1.0.0f 1 - +v0.7.12 2012-06-19 osx-x64-pkg,src,win-x64-exe,win-x86-exe,win-x86-msi 1.1.30 3.11.10.0 0.6 1.2.3 1.0.0f 1 - +v0.7.11 2012-06-15 osx-x64-pkg,src,win-x64-exe,win-x64-msi,win-x86-exe,win-x86-msi 1.1.26 3.11.10.0 0.6 1.2.3 1.0.0f 1 - +v0.7.10 2012-06-11 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.25 3.9.24.31 0.6 1.2.3 1.0.0f 1 - +v0.7.9 2012-05-29 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.23 3.11.1.0 0.6 1.2.3 1.0.0f 1 - +v0.7.8 2012-04-18 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.18 3.9.24.9 0.6 1.2.3 1.0.0f 1 - +v0.7.7 2012-03-30 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.15 3.9.24.7 0.6 1.2.3 0.9.8r 1 - +v0.7.6 2012-03-31 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.8 3.9.17.0 0.6 1.2.3 0.9.8r 1 - +v0.7.5 2012-03-31 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.1 3.9.5.0 0.6 1.2.3 0.9.8r 1 - +v0.7.4 2012-03-31 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.1 3.9.5.0 0.6 1.2.3 0.9.8r 1 - +v0.7.3 2012-03-31 osx-x64-pkg,src,win-x86-exe 1.1.0-3 3.9.2.0 0.6 1.2.3 0.9.8r 1 - +v0.7.2 2012-03-31 osx-x64-pkg,src,win-x86-exe 1.1.0-3 3.8.9.0 0.6 1.2.3 0.9.8r 1 - +v0.7.1 2012-01-23 osx-x64-pkg,src,win-x86-exe 1.1.0-2 3.8.8.0 0.6 1.2.3 0.9.8r 1 - +v0.7.0 2012-01-17 osx-x64-pkg,src,win-x86-exe 1.1.0-2 3.8.6.0 0.6 1.2.3 0.9.8r 1 - +v0.6.21 2012-08-03 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.37 3.6.6.25 0.6 1.2.3 0.9.8r 1 - +v0.6.20 2012-07-10 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.37 3.6.6.25 0.6 1.2.3 0.9.8r 1 - +v0.6.19 2012-06-08 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.24 3.6.6.25 0.6 1.2.3 0.9.8r 1 - +v0.6.18 2012-05-14 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.21 3.6.6.25 0.6 1.2.3 0.9.8r 1 - +v0.6.17 2012-05-04 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.21 3.6.6.25 0.6 1.2.3 0.9.8r 1 - +v0.6.16 2012-04-27 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.19 3.6.6.25 0.6 1.2.3 0.9.8r 1 - +v0.6.15 2012-04-09 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.16 3.6.6.24 0.6 1.2.3 0.9.8r 1 - +v0.6.14 2012-03-23 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.12 3.6.6.24 0.6 1.2.3 0.9.8r 1 - +v0.6.13 2012-03-31 osx-x64-pkg,src,win-x64-exe,win-x86-exe 1.1.9 3.6.6.24 0.6 1.2.3 0.9.8r 1 - +v0.6.12 2012-03-02 osx-x64-pkg,src,win-x86-exe 1.1.4 3.6.6.24 0.6 1.2.3 0.9.8r 1 - +v0.6.11 2012-02-17 osx-x64-pkg,src,win-x86-exe 1.1.1 3.6.6.20 0.6 1.2.3 0.9.8r 1 - +v0.6.10 2012-02-04 osx-x64-pkg,src,win-x86-exe 1.1.0-3 3.6.6.20 0.6 1.2.3 0.9.8r 1 - +v0.6.9 2012-01-27 osx-x64-pkg,src,win-x86-exe 1.1.0-3 3.6.6.19 0.6 1.2.3 0.9.8r 1 - +v0.6.8 2012-01-23 osx-x64-pkg,src,win-x86-exe 1.1.0-2 3.6.6.19 0.6 1.2.3 0.9.8r 1 - +v0.6.7 2012-01-07 osx-x64-pkg,src,win-x86-exe 1.1.0-beta-10 3.6.6.15 0.6 1.2.3 0.9.8r 1 - +v0.6.6 2012-03-31 osx-x64-pkg,src,win-x86-exe 1.1.0-beta-4 3.6.6.14 0.6 1.2.3 0.9.8r 1 - +v0.6.5 2012-03-31 osx-x64-pkg,src,win-x86-exe 1.1.0-alpha-6 3.6.6.11 0.6 1.2.3 0.9.8r 1 - +v0.6.4 2011-12-03 osx-x64-pkg,src,win-x86-exe 1.1.0-alpha-6 3.6.6.8 0.6 1.2.3 0.9.8r 1 - +v0.6.3 2011-11-25 osx-x64-pkg,src,win-x86-exe 1.1.0-alpha-2 3.6.6.8 0.6 1.2.3 0.9.8r 1 - +v0.6.2 2011-11-18 osx-x64-pkg,src,win-x86-exe - 3.6.6.8 0.6 1.2.3 0.9.8r 1 - +v0.6.1 2011-11-11 osx-x64-pkg,src,win-x86-exe - 3.6.6.7 0.1 1.2.3 0.9.8r 1 - +v0.6.0 2011-11-04 src,win-x86-exe - 3.6.6.6 0.1 1.2.3 0.9.8r 1 - +v0.5.10 2011-10-22 src,win-x86-exe - 3.7.0.0 0.1 1.2.3 0.9.8r 1 - +v0.5.9 2011-10-11 src,win-x86-exe - 3.6.4.0 0.1 1.2.3 0.9.8r 1 - +v0.5.8 2011-09-30 src,win-x86-exe - 3.6.4.0 0.1 1.2.3 0.9.8r 1 - +v0.5.7 2011-09-16 src,win-x86-exe - 3.6.4.0 0.1 - 0.9.8r 1 - +v0.5.6 2011-08-26 src,win-x86-exe - 3.6.2.0 0.1 - 0.9.8r 1 - +v0.5.5 2011-08-26 src,win-x86-exe - 3.5.8.0 0.1 - 0.9.8r 1 - +v0.5.4 2011-08-26 src,win-x86-exe - 3.5.4.3 0.1 - - 1 - +v0.5.3 2011-08-26 src,win-x86-exe - 3.4.14.0 0.1 - - 1 - +v0.5.2 2011-08-26 src,win-x86-exe - 3.4.14.0 0.1 - - 1 - +v0.5.1 2011-08-26 src,win-x86-exe - 3.4.10.0 0.1 - - 1 - +v0.5.0 2011-08-26 src - 3.1.8.25 - - - 1 - +v0.4.12 2015-10-17 src - 3.1.8.26 - - - 1 - +v0.4.11 2011-08-26 src - 3.1.8.26 - - - 1 - +v0.4.10 2011-08-26 src - 3.1.8.26 - - - 1 - +v0.4.9 2011-08-26 src - 3.1.8.25 - - - 1 - +v0.4.8 2011-08-26 src - 3.1.8.16 - - - 1 - +v0.4.7 2011-08-26 src - 3.1.8.10 - - - 1 - +v0.4.6 2011-08-26 src - 3.1.8.10 - - - 1 - +v0.4.5 2011-08-26 src - 3.1.8.8 - - - 1 - +v0.4.4 2011-08-26 src - 3.1.8.5 - - - 1 - +v0.4.3 2011-08-26 src - 3.1.8.3 - - - 1 - +v0.4.2 2011-08-26 src - 3.1.8.0 - - - 1 - +v0.4.1 2011-08-26 src - 3.1.5.0 - - - 1 - +v0.4.0 2011-08-26 src - 3.1.2.0 - - - 1 - +v0.3.8 2011-08-26 src - 3.1.1.0 - - - 1 - +v0.3.7 2011-08-26 src - 3.0.10.0 - - - 1 - +v0.3.6 2011-08-26 src - 3.0.9.0 - - - 1 - +v0.3.5 2011-08-26 src - 3.0.4.1 - - - 1 - +v0.3.4 2011-08-26 src - 3.0.4.1 - - - 1 - +v0.3.3 2011-08-26 src - 3.0.4.1 - - - 1 - +v0.3.2 2011-08-26 src - 3.0.3.0 - - - 1 - +v0.3.1 2011-08-26 src - 2.5.3.0 - - - 1 - +v0.3.0 2011-08-26 src - 2.5.1.0 - - - 1 - +v0.2.6 2011-08-26 src - 2.3.8.0 - - - 1 - +v0.2.5 2011-08-26 src - 2.3.8.0 - - - 1 - +v0.2.4 2011-08-26 src - 2.3.8.0 - - - 1 - +v0.2.3 2011-08-26 src - 2.3.8.0 - - - 1 - +v0.2.2 2011-08-26 src - 2.3.8.0 - - - 1 - +v0.2.1 2011-08-26 src - 2.3.8.0 - - - 1 - +v0.2.0 2011-08-26 src - 2.3.8.0 - - - 1 - +v0.1.104 2011-08-26 src - 2.3.6.1 - - - 1 - +v0.1.103 2011-08-26 src - 2.3.5.0 - - - 1 - +v0.1.102 2011-08-26 src - 2.3.2.0 - - - 1 - +v0.1.101 2011-08-26 src - 2.3.0.0 - - - 1 - +v0.1.100 2011-08-26 src - 2.2.21.0 - - - - - +v0.1.99 2011-08-26 src - 2.2.18.0 - - - - - +v0.1.98 2011-08-26 src - 2.2.16.0 - - - - - +v0.1.97 2011-08-26 src - 2.2.12.0 - - - - - +v0.1.96 2011-08-26 src - 2.2.0 - - - - - +v0.1.95 2011-08-26 src - 2.2.0 - - - - - +v0.1.94 2011-08-26 src - 2.2.8.0 - - - - - +v0.1.93 2011-08-26 src - 2.2.6.0 - - - - - +v0.1.92 2011-08-26 src - 2.2.4.2 - - - - - +v0.1.91 2011-08-26 src - 2.2.3.1 - - - - - +v0.1.90 2011-08-26 src - 2.2.0.3 - - - - - +v0.1.33 2011-08-26 src - 2.1.6.0 - - - - - +v0.1.32 2011-08-26 src - 2.1.3.0 - - - - - +v0.1.31 2011-08-26 src - 2.1.2.0 - - - - - +v0.1.30 2011-08-26 src - 2.1.1.1 - - - - - +v0.1.29 2011-08-26 src - 2.1.0.0 - - - - - +v0.1.28 2011-08-26 src - 2.1.0.0 - - - - - +v0.1.27 2011-08-26 src - 2.1.0.0 - - - - - +v0.1.26 2011-08-26 src - 2.0.6.1 - - - - - +v0.1.25 2011-08-26 src - 2.0.5.4 - - - - - +v0.1.24 2011-08-26 src - 2.0.5.4 - - - - - +v0.1.23 2011-08-26 src - 2.0.0 - - - - - +v0.1.22 2011-08-26 src - 2.0.0 - - - - - +v0.1.21 2011-08-26 src - 2.0.0 - - - - - +v0.1.20 2011-08-26 src - 2.0.2.0 - - - - - +v0.1.19 2011-08-26 src - 2.0.2.0 - - - - - +v0.1.18 2011-08-26 src - 1.3.18.0 - - - - - +v0.1.17 2011-08-26 src - 1.3.18.0 - - - - - +v0.1.16 2011-08-26 src - 1.3.18.0 - - - - - +v0.1.15 2011-08-26 src - 1.3.16.0 - - - - - +v0.1.14 2011-08-26 src - 1.3.15.0 - - - - - diff --git a/test/fast/Unit tests/nvm_add_iojs_prefix b/test/fast/Unit tests/nvm_add_iojs_prefix new file mode 100755 index 0000000..4a8d1ee --- /dev/null +++ b/test/fast/Unit tests/nvm_add_iojs_prefix @@ -0,0 +1,9 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "_$(nvm_add_iojs_prefix 1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix 1" did not return "iojs-v1"' +[ "_$(nvm_add_iojs_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix iojs-1" did not return "iojs-v1"' +[ "_$(nvm_add_iojs_prefix iojs-1.2.3)" = "_iojs-v1.2.3" ] || die '"nvm_add_iojs_prefix iojs-1.2.3" did not return "iojs-v1.2.3"' diff --git a/test/fast/Unit tests/nvm_alias b/test/fast/Unit tests/nvm_alias new file mode 100755 index 0000000..f51aac8 --- /dev/null +++ b/test/fast/Unit tests/nvm_alias @@ -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 + diff --git a/test/fast/Unit tests/nvm_alias_path b/test/fast/Unit tests/nvm_alias_path new file mode 100755 index 0000000..0766e2a --- /dev/null +++ b/test/fast/Unit tests/nvm_alias_path @@ -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" + diff --git a/test/fast/Unit tests/nvm_checksum b/test/fast/Unit tests/nvm_checksum new file mode 100755 index 0000000..73cf1f1 --- /dev/null +++ b/test/fast/Unit tests/nvm_checksum @@ -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 diff --git a/test/fast/Unit tests/nvm_die_on_prefix b/test/fast/Unit tests/nvm_die_on_prefix new file mode 100755 index 0000000..9a0260d --- /dev/null +++ b/test/fast/Unit tests/nvm_die_on_prefix @@ -0,0 +1,74 @@ +#!/bin/sh + +cleanup () { + alias nvm_has='\nvm_has' + alias npm='\npm' + unset -f nvm_has npm +} +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +OUTPUT="$(nvm_die_on_prefix 2>&1)" +EXPECTED_OUTPUT="First argument \"delete the prefix\" must be zero or one" +EXIT_CODE="$(nvm_die_on_prefix >/dev/null 2>&1; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'" +[ "_$EXIT_CODE" = "_1" ] || die "'nvm_die_on_prefix' did not exit with 1; got "$EXIT_CODE"" + +OUTPUT="$(nvm_die_on_prefix 2 2>&1)" +EXPECTED_OUTPUT="First argument \"delete the prefix\" must be zero or one" +EXIT_CODE="$(nvm_die_on_prefix 2 >/dev/null 2>&1; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 2' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'" +[ "_$EXIT_CODE" = "_1" ] || die "'nvm_die_on_prefix' did not exit with 1; got "$EXIT_CODE"" + +OUTPUT="$(nvm_die_on_prefix 0 2>&1)" +EXPECTED_OUTPUT="Second argument \"nvm command\" must be nonempty" +EXIT_CODE="$(nvm_die_on_prefix 0 >/dev/null 2>&1; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'" +[ "_$EXIT_CODE" = "_2" ] || die "'nvm_die_on_prefix 0' did not exit with 2; got '$EXIT_CODE'" + +nvm_has() { return 1; } # ie, npm is not installed +OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)" +[ -z "$OUTPUT" ] || die "nvm_die_on_prefix was not a noop when nvm_has returns 1, got '$OUTPUT'" + +nvm_has() { return 0; } + +npm() { + local args + args="$@" + if [ "_$args" = "_config get prefix" ]; then + echo "$(nvm_version_dir new)/good prefix" + fi +} +OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)" +[ -z "$OUTPUT" ] || die "'nvm_die_on_prefix' was not a noop when prefix is good; got '$OUTPUT'" + +OUTPUT="$(PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)" +EXPECTED_OUTPUT='nvm is not compatible with the "PREFIX" environment variable: currently set to "bar" +Run `unset PREFIX` to unset it.' +EXIT_CODE="$(PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'" +[ "_$EXIT_CODE" = "_3" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 3; got '$EXIT_CODE'" + +OUTPUT="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)" +EXPECTED_OUTPUT='nvm is not compatible with the "NPM_CONFIG_PREFIX" environment variable: currently set to "bar" +Run `unset NPM_CONFIG_PREFIX` to unset it.' +EXIT_CODE="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'" +[ "_$EXIT_CODE" = "_4" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'" + +npm() { + local args + args="$@" + if [ "_$args" = "_config get prefix" ]; then + echo "./bad prefix" + fi +} +OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)" +EXPECTED_OUTPUT="nvm is not compatible with the npm config \"prefix\" option: currently set to \"./bad prefix\" +Run \`npm config delete prefix\` or \`foo\` to unset it." +EXIT_CODE="$(nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT' with bad prefix set; got '$OUTPUT'" +[ "_$EXIT_CODE" = "_10" ] || die "'nvm_die_on_prefix 0 foo' did not exit with 10 with bad prefix set; got '$EXIT_CODE'" + +cleanup diff --git a/test/fast/Unit tests/nvm_ensure_default_set b/test/fast/Unit tests/nvm_ensure_default_set new file mode 100755 index 0000000..edd926c --- /dev/null +++ b/test/fast/Unit tests/nvm_ensure_default_set @@ -0,0 +1,13 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +EXPECTED_OUTPUT="nvm_ensure_default_set: a version is required" +OUTPUT="$(nvm_ensure_default_set 2>&1 >/dev/null)" +EXIT_CODE="$?" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_ensure_default_set' did not output "$EXPECTED_OUTPUT", got "$OUTPUT"" +[ "_$EXIT_CODE" = "_1" ] || die "'nvm_ensure_default_set' did not exit with 1, got "$EXIT_CODE"" + +# see test/fast/Aliases for remaining nvm_ensure_default_set tests diff --git a/test/fast/Unit tests/nvm_ensure_version_installed b/test/fast/Unit tests/nvm_ensure_version_installed new file mode 100755 index 0000000..492cc95 --- /dev/null +++ b/test/fast/Unit tests/nvm_ensure_version_installed @@ -0,0 +1,30 @@ +#!/bin/sh + +die () { echo $@ ; cleanup ; exit 1; } +cleanup () { + rm -rf "$(nvm_version_path v0.1.2)" +} + +. ../../../nvm.sh + +mkdir -p "$(nvm_version_path v0.1.2)" + +OUTPUT="$(nvm_ensure_version_installed foo 2>&1)" +EXIT_CODE=$? +EXPECTED_OUTPUT='N/A: version "foo" is not yet installed' +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed foo' to give $EXPECTED_OUTPUT, got $OUTPUT" +[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed foo' to exit with 1, got $EXIT_CODE" + +OUTPUT="$(nvm_ensure_version_installed 0.1)" +EXIT_CODE=$? +[ "_$OUTPUT" = "_" ] || die "expected 'nvm_ensure_version_installed 0.1' to have no output, got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm_ensure_version_installed 0.1' to exit with 0, got $EXIT_CODE" + +# Special case for "iojs" +OUTPUT="$(nvm_ensure_version_installed iojs 2>&1)" +EXIT_CODE=$? +EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed' +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed iojs' to give $EXPECTED_OUTPUT, got $OUTPUT" +[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed iojs' to exit with 1, got $EXIT_CODE" + +cleanup diff --git a/test/fast/Unit tests/nvm_ensure_version_prefix b/test/fast/Unit tests/nvm_ensure_version_prefix new file mode 100755 index 0000000..184ddea --- /dev/null +++ b/test/fast/Unit tests/nvm_ensure_version_prefix @@ -0,0 +1,12 @@ +#!/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"' + +[ "_$(nvm_ensure_version_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-1" did not return "iojs-v1"' +[ "_$(nvm_ensure_version_prefix iojs-v1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-v1" did not return "iojs-v1"' diff --git a/test/fast/Unit tests/nvm_find_up b/test/fast/Unit tests/nvm_find_up new file mode 100755 index 0000000..39fb568 --- /dev/null +++ b/test/fast/Unit tests/nvm_find_up @@ -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 + diff --git a/test/fast/Unit tests/nvm_format_version b/test/fast/Unit tests/nvm_format_version new file mode 100755 index 0000000..134ca75 --- /dev/null +++ b/test/fast/Unit tests/nvm_format_version @@ -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" + diff --git a/test/fast/Unit tests/nvm_get_arch b/test/fast/Unit tests/nvm_get_arch new file mode 100755 index 0000000..b3fd51b --- /dev/null +++ b/test/fast/Unit tests/nvm_get_arch @@ -0,0 +1,80 @@ +#!/bin/sh + +# Save the PATH as it was when the test started to restore it when it +# finishes +ORIG_PATH=$PATH + +cleanup() { + # Restore the PATH as it was when the test started + export PATH=ORIG_PATH +} + +die () { cleanup; echo $@ ; exit 1; } + +. ../../../nvm.sh + +# Directory where mocked binaries used by nvm_get_arch for each OS/arch are +# located +MOCKS_DIR=`pwd`/../../mocks +# Sets the PATH for these tests to include the symlinks to the mocked +# binaries +export PATH=.:${PATH} + +# Setups mock binaries for a given OS and arch that mimic +# the output of the real binaries used by nvm_get_arch to guess +# the architecture of a given system. +setup_mock_arch() { + local OS=$1 + local ARCH=$2 + local OPT=$3 + + if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then + ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo + if [ "_$OPT" != "_no_pkg_info" ]; then + ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info + fi + fi + + ln -sf "${MOCKS_DIR}/uname_${OS}_${ARCH}" ./uname +} + +# Cleans up the setup done by setup_mock_arch. +cleanup_mock_arch() { + local OS=$1 + local ARCH=$2 + + if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then + rm -f ./isainfo + rm -f ./pkg_info + fi + + rm -f ./uname +} + +# Runs nvm_get_arch for architecture $ARCH and OS $OS, and compares the +# expected output $EXPECTED_OUTPUT with the actual output. Does nothing +# and exits cleanly if they match, dies otherwise. +run_test() { + local ARCH=$1 + local OS=$2 + local EXPECTED_OUTPUT=$3 + local OPT=$4 + + setup_mock_arch $OS $ARCH $OPT + local OUTPUT="$(nvm_get_arch)" + cleanup_mock_arch $OS $ARCH + [ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || + die "nvm_get_arch for OS \"$OS\" and arch \"$ARCH\" with OPT \"$OPT\" did + not return \"$EXPECTED_OUTPUT\"; got \"$OUTPUT\"" +} + +run_test x86 smartos x86 +run_test x86 smartos x86 no_pkg_info + +run_test amd64 smartos x64 +run_test amd64 smartos x64 no_pkg_info + +run_test x86 osx x86 +run_test amd64 osx x64 + +cleanup diff --git a/test/fast/Unit tests/nvm_get_latest missing curl or wget b/test/fast/Unit tests/nvm_get_latest missing curl or wget new file mode 100755 index 0000000..1ad960a --- /dev/null +++ b/test/fast/Unit tests/nvm_get_latest missing curl or wget @@ -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 diff --git a/test/fast/Unit tests/nvm_has b/test/fast/Unit tests/nvm_has new file mode 100755 index 0000000..437d26f --- /dev/null +++ b/test/fast/Unit tests/nvm_has @@ -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" + diff --git a/test/fast/Unit tests/nvm_has_solaris_binary b/test/fast/Unit tests/nvm_has_solaris_binary new file mode 100755 index 0000000..5a29112 --- /dev/null +++ b/test/fast/Unit tests/nvm_has_solaris_binary @@ -0,0 +1,32 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh +. ../../common.sh + +# Invalid version numbers fail +assert_not_ok nvm_has_solaris_binary "" +assert_not_ok nvm_has_solaris_binary "foo" + +# "Invalid" node version numbers fail +assert_not_ok nvm_has_solaris_binary "v1.0.0" +assert_not_ok nvm_has_solaris_binary "v3.3.1" + +# Valid io.js version numbers that have a Solaris binary succeed +assert_ok nvm_has_solaris_binary "iojs-v3.3.1" + +# Invvalid io.js version numbers fail +assert_not_ok nvm_has_solaris_binary "iojs-v0.12.7" + +# Valid node version numbers that don't have a Solaris binary fail +assert_not_ok nvm_has_solaris_binary "v0.8.5" + +# Valid node version numbers that have a Solaris binary succeed +assert_ok nvm_has_solaris_binary "v0.8.6" +assert_ok nvm_has_solaris_binary "v0.10.0" +assert_ok nvm_has_solaris_binary "v0.12.7" + +# Valid "merged" version numbers succeed +assert_ok nvm_has_solaris_binary "v4.0.0" +assert_ok nvm_has_solaris_binary "v4.1.1" diff --git a/test/fast/Unit tests/nvm_has_system_iojs b/test/fast/Unit tests/nvm_has_system_iojs new file mode 100755 index 0000000..bb58da6 --- /dev/null +++ b/test/fast/Unit tests/nvm_has_system_iojs @@ -0,0 +1,31 @@ +#!/bin/sh + +cleanup () { + rm ../../../versions/io.js/v0.1.2/node + rm ../../../versions/io.js/v0.1.2/iojs + rmdir ../../../versions/io.js/v0.1.2 +} +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +mkdir ../../../versions/io.js/v0.1.2 +touch ../../../versions/io.js/v0.1.2/node +touch ../../../versions/io.js/v0.1.2/iojs + +nvm use iojs-v0.1.2 + +if command -v iojs; then + nvm_has_system_iojs +else + ! nvm_has_system_iojs +fi + +nvm deactivate /dev/null 2>&1 + +if command -v iojs; then + nvm_has_system_iojs +else + ! nvm_has_system_iojs +fi + diff --git a/test/fast/Unit tests/nvm_has_system_node b/test/fast/Unit tests/nvm_has_system_node new file mode 100755 index 0000000..6265d00 --- /dev/null +++ b/test/fast/Unit tests/nvm_has_system_node @@ -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 + diff --git a/test/fast/Unit tests/nvm_iojs_prefix b/test/fast/Unit tests/nvm_iojs_prefix new file mode 100755 index 0000000..6666695 --- /dev/null +++ b/test/fast/Unit tests/nvm_iojs_prefix @@ -0,0 +1,7 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "$(nvm_iojs_prefix)" = "iojs" ] || die '"nvm_iojs_prefix" did not return the string "iojs". why did this fail?!' diff --git a/test/fast/Unit tests/nvm_is_alias b/test/fast/Unit tests/nvm_is_alias new file mode 100755 index 0000000..b5cf305 --- /dev/null +++ b/test/fast/Unit tests/nvm_is_alias @@ -0,0 +1,20 @@ +#!/bin/sh + +cleanup () { unalias foo; unalias grep; } +die () { echo $@ ; cleanup ; exit 1; } + +. ../../../nvm.sh + +alias foo='bar' +nvm_is_alias foo || die '"nvm_is_alias foo" was not true' + +! nvm_is_alias nvm_is_alias || die '"nvm_is_alias nvm_is_alias was not false' + +alias grep='grep' +unalias grep || die '"unalias grep" failed' +! nvm_is_alias grep || die '"nvm_is_alias grep" with unaliased grep was not false' + +alias grep='grep' +nvm_is_alias grep || die '"nvm_is_alias grep" with aliased grep was not true' + +cleanup diff --git a/test/fast/Unit tests/nvm_is_iojs_version b/test/fast/Unit tests/nvm_is_iojs_version new file mode 100755 index 0000000..e2f5e3f --- /dev/null +++ b/test/fast/Unit tests/nvm_is_iojs_version @@ -0,0 +1,10 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm_is_iojs_version 'iojs-' || die '"nvm_is_iojs_version iojs- was not true' +nvm_is_iojs_version 'iojs-foo' || die '"nvm_is_iojs_version iojs- was not true' +! nvm_is_iojs_version 'iojs' || die '"nvm_is_iojs_version iojs was not false' +! nvm_is_iojs_version 'v1.0.0' || die '"nvm_is_iojs_version v1.0.0" was not false' diff --git a/test/fast/Unit tests/nvm_is_merged_node_version b/test/fast/Unit tests/nvm_is_merged_node_version new file mode 100755 index 0000000..7cf5334 --- /dev/null +++ b/test/fast/Unit tests/nvm_is_merged_node_version @@ -0,0 +1,10 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm_is_merged_node_version '4.0' || die '"nvm_is_merged_node_version 4.0 was not true' +nvm_is_merged_node_version '5.1' || die '"nvm_is_merged_node_version 5.1 was not true' +! nvm_is_merged_node_version '3.99' || die '"nvm_is_merged_node_version 3.99 was not false' +! nvm_is_merged_node_version 'v1.0.0' || die '"nvm_is_merged_node_version v1.0.0" was not false' diff --git a/test/fast/Unit tests/nvm_is_natural_num b/test/fast/Unit tests/nvm_is_natural_num new file mode 100755 index 0000000..e9b0668 --- /dev/null +++ b/test/fast/Unit tests/nvm_is_natural_num @@ -0,0 +1,17 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +! nvm_is_natural_num || die 'no args is not false' +! nvm_is_natural_num '' || die 'empty string is not false' +! nvm_is_natural_num a || die 'a is not false' +! nvm_is_natural_num -1 || 'negative number is not false' +! nvm_is_natural_num --1 || 'double negative number is not false' +! nvm_is_natural_num 1.2 || 'decimal number is not false' +! nvm_is_natural_num 0 || die 'zero is not false' + +nvm_is_natural_num 1 || die '1 is not true' +nvm_is_natural_num 2 || die '2 is not true' +nvm_is_natural_num 1234 || die '1234 is not true' diff --git a/test/fast/Unit tests/nvm_is_valid_version b/test/fast/Unit tests/nvm_is_valid_version new file mode 100755 index 0000000..d34f767 --- /dev/null +++ b/test/fast/Unit tests/nvm_is_valid_version @@ -0,0 +1,13 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm_is_valid_version 0.1.2 || die "nvm_is_valid_version 0.1.2 did not return 0" +nvm_is_valid_version foo && die "nvm_is_valid_version foo did not return 1" +nvm_is_valid_version iojs-1 || die "nvm_is_valid_version iojs-1 did not return 0" +nvm_is_valid_version iojs || die "nvm_is_valid_version iojs did not return 0" +nvm_is_valid_version node || die "nvm_is_valid_version node did not return 0" +nvm_is_valid_version stable || die "nvm_is_valid_version stable did not return 0" +nvm_is_valid_version unstable || die "nvm_is_valid_version unstable did not return 0" diff --git a/test/fast/Unit tests/nvm_ls_current b/test/fast/Unit tests/nvm_ls_current new file mode 100755 index 0000000..bc4a4f5 --- /dev/null +++ b/test/fast/Unit tests/nvm_ls_current @@ -0,0 +1,37 @@ +#!/bin/sh + +TEST_PWD=$(pwd) +TEST_DIR="$TEST_PWD/nvm_ls_current_tmp" + +cleanup() { rm -rf "$TEST_DIR"; unset -f return_zero; alias node='node' ; unalias node; } +die () { echo $@ ; cleanup ; exit 1; } + +. ../../../nvm.sh + +return_zero () { return 0; } + +if nvm_has_system_node || nvm_has_system_iojs; then + EXPECTED_SYSTEM_NODE="system" +else + EXPECTED_SYSTEM_NODE="none" +fi +[ "_$(nvm deactivate > /dev/null 2>&1 ; nvm_ls_current)" = "_$EXPECTED_SYSTEM_NODE" ] || die "when deactivated, did not return $EXPECTED_SYSTEM_NODE" + +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 diff --git a/test/fast/Unit tests/nvm_ls_remote b/test/fast/Unit tests/nvm_ls_remote new file mode 100755 index 0000000..dbb6358 --- /dev/null +++ b/test/fast/Unit tests/nvm_ls_remote @@ -0,0 +1,57 @@ +#!/bin/sh + +die () { echo $@ ; cleanup ; exit 1; } + +cleanup() { + unset -f nvm_download +} + +. ../../../nvm.sh + +# sample output at the time the test was written +TAB_PATH="$PWD/nodejs.org-dist-index.tab" +nvm_download() { + cat "$TAB_PATH" +} + +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="5.3" +[ "_$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="v5.3.0" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT" + +OUTPUT="$(nvm_ls_remote unstable)" +EXPECTED_OUTPUT="v0.11.16" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT" + +cleanup + diff --git a/test/fast/Unit tests/nvm_ls_remote_iojs b/test/fast/Unit tests/nvm_ls_remote_iojs new file mode 100755 index 0000000..d93e077 --- /dev/null +++ b/test/fast/Unit tests/nvm_ls_remote_iojs @@ -0,0 +1,36 @@ +#!/bin/sh + +die () { echo $@ ; cleanup ; exit 1; } + +cleanup() { + unset -f nvm_download +} + +. ../../../nvm.sh + +# sample output at the time the test was written +TAB_PATH="$PWD/iojs.org-dist-index.tab" +nvm_download() { + cat "$TAB_PATH" +} + +OUTPUT="$(nvm_ls_remote_iojs foo)" +EXIT_CODE="$(nvm_ls_remote_iojs foo >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A" +[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE" + +OUTPUT="$(nvm_ls_remote_iojs)" +EXPECTED_OUTPUT="$(nvm_download | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | sed -e 's/^/iojs-/')" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote_iojs did not output expected sorted versions; got $(echo "$OUTPUT") expected $(echo "$EXPECTED_OUTPUT")" + +OUTPUT="$(nvm_ls_remote_iojs 1.0)" +EXPECTED_OUTPUT="iojs-v1.0.0 +iojs-v1.0.1 +iojs-v1.0.2 +iojs-v1.0.3 +iojs-v1.0.4" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote_iojs 1.0 did not output 1.0.x versions; got $OUTPUT" + +cleanup + diff --git a/test/fast/Unit tests/nvm_node_prefix b/test/fast/Unit tests/nvm_node_prefix new file mode 100755 index 0000000..a0bc098 --- /dev/null +++ b/test/fast/Unit tests/nvm_node_prefix @@ -0,0 +1,7 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "$(nvm_node_prefix)" = "node" ] || die '"nvm_node_prefix" did not return the string "node". why did this fail?!' diff --git a/test/fast/Unit tests/nvm_num_version_groups b/test/fast/Unit tests/nvm_num_version_groups new file mode 100755 index 0000000..88c240e --- /dev/null +++ b/test/fast/Unit tests/nvm_num_version_groups @@ -0,0 +1,25 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0" +[ "~$(nvm_num_version_groups v)" = "~0" ] || die "just "v" should give 0" +[ "~$(nvm_num_version_groups .)" = "~0" ] || die "just "." 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 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 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" + diff --git a/test/fast/Unit tests/nvm_prepend_path b/test/fast/Unit tests/nvm_prepend_path new file mode 100755 index 0000000..ef0af81 --- /dev/null +++ b/test/fast/Unit tests/nvm_prepend_path @@ -0,0 +1,18 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +TEST_PATH=/usr/bin:/usr/local/bin + +NEW_PATH=`nvm_prepend_path "$TEST_PATH" "$NVM_DIR/v0.2.5/bin"` + +[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly prepended: $NEW_PATH " + + +EMPTY_PATH= + +NEW_PATH=`nvm_prepend_path "$EMPTY_PATH" "$NVM_DIR/v0.2.5/bin"` + +[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin" ] || die "Not correctly prepended: $NEW_PATH " diff --git a/test/fast/Unit tests/nvm_print_implicit_alias errors b/test/fast/Unit tests/nvm_print_implicit_alias errors new file mode 100755 index 0000000..a617383 --- /dev/null +++ b/test/fast/Unit tests/nvm_print_implicit_alias errors @@ -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', 'unstable', 'iojs', and 'node' are supported." +[ "_$(nvm_print_implicit_alias local 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \ + || die "nvm_print_implicit_alias did not require stable|unstable|iojs|node as second argument" +[ "_$(nvm_print_implicit_alias local foo 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \ + || die "nvm_print_implicit_alias did not require stable|unstable|iojs|node 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|iojs|node had wrong exit code: expected 2, got $SECOND_EXIT_CODE" + diff --git a/test/fast/Unit tests/nvm_print_implicit_alias success b/test/fast/Unit tests/nvm_print_implicit_alias success new file mode 100755 index 0000000..425350f --- /dev/null +++ b/test/fast/Unit tests/nvm_print_implicit_alias success @@ -0,0 +1,105 @@ +#!/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 + rm -rf ../../../versions/io.js/v0.98.0 + rm -rf ../../../versions/node/v1.0.0 + rm -rf ../../../versions/node/v1.1.0 + unset -f nvm_ls_remote nvm_ls_remote_iojs +} + +. ../../../nvm.sh + +mkdir ../../../v0.2.3 +mkdir ../../../v0.3.4 +mkdir ../../../v0.4.6 +mkdir ../../../v0.5.7 +mkdir ../../../v0.7.7 +mkdir -p ../../../versions/io.js/v0.98.0 + +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_NODE="$(nvm_print_implicit_alias local node)" +[ "_$LATEST_NODE" = "_stable" ] || die "local node is not stable: expected stable, got $LATEST_NODE" + +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" + +LATEST_IOJS="$(nvm_print_implicit_alias local iojs)" +[ "_$LATEST_IOJS" = "_iojs-v0.98" ] || die "local iojs is not latest iojs: expected iojs-v0.98, got $LATEST_IOJS" + +## node post v1.0/io.js merger ## +mkdir -p ../../../versions/node/v1.0.0 +mkdir -p ../../../versions/node/v1.1.0 + +LATEST_STABLE="$(nvm_print_implicit_alias local stable)" +[ "_$LATEST_STABLE" = "_1.1" ] || die "local stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE" + +LATEST_UNSTABLE="$(nvm_print_implicit_alias local unstable)" +[ "_$LATEST_UNSTABLE" = "_0.7" ] || die "local unstable is not latest pre-v1.0 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" +} + +nvm_ls_remote_iojs() { + echo "iojs-v0.1.0" + echo "iojs-v0.1.1" + echo "iojs-v0.7.8" + echo "iojs-v0.98.5" + echo "iojs-v0.99.0" +} + +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_NODE="$(nvm_print_implicit_alias remote node)" +[ "_$LATEST_NODE" = "_stable" ] || die "remote node is not stable: expected stable, got $LATEST_NODE" + +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" + +LATEST_IOJS="$(nvm_print_implicit_alias remote iojs)" +[ "_$LATEST_IOJS" = "_iojs-v0.99" ] || die "remote iojs is not latest: expected iojs-v0.99, got $LATEST_IOJS" + +## node post v1.0/io.js merger ## +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" + echo "v1.0.0" + echo "v1.1.0" +} + +LATEST_STABLE="$(nvm_print_implicit_alias remote stable)" +[ "_$LATEST_STABLE" = "_1.1" ] || die "remote stable when post-v1.0 exists is not latest: expected 1.1, got $LATEST_STABLE" + +LATEST_UNSTABLE="$(nvm_print_implicit_alias remote unstable)" +[ "_$LATEST_UNSTABLE" = "_0.9" ] || die "remote unstable is not latest odd pre-v1.0 minor: expected 0.9, got $LATEST_UNSTABLE" +## ** ## + +cleanup + diff --git a/test/fast/Unit tests/nvm_print_npm_version b/test/fast/Unit tests/nvm_print_npm_version new file mode 100755 index 0000000..2bf24a0 --- /dev/null +++ b/test/fast/Unit tests/nvm_print_npm_version @@ -0,0 +1,28 @@ +#!/bin/sh + +cleanup () { + alias nvm_has='\nvm_has' + alias npm='\npm' + unset -f nvm_has npm +} +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm_has() { return 1; } +OUTPUT="$(nvm_print_npm_version)" +[ -z "$OUTPUT" ] || die "nvm_print_npm_version did not return empty when nvm_has returns 1, got '$OUTPUT'" + +nvm_has() { return 0; } +npm() { + if [ "_$@" = "_--version" ]; then + echo "1.2.3" + else + echo "error" + fi +} +OUTPUT="$(nvm_print_npm_version)" +EXPECTED_OUTPUT=" (npm v1.2.3)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_npm_version did not provided '$EXPECTED_OUTPUT', got '$OUTPUT'" + +cleanup diff --git a/test/fast/Unit tests/nvm_remote_version b/test/fast/Unit tests/nvm_remote_version new file mode 100755 index 0000000..39fa34d --- /dev/null +++ b/test/fast/Unit tests/nvm_remote_version @@ -0,0 +1,78 @@ +#!/bin/sh + +die () { echo $@ ; cleanup ; exit 1; } + +cleanup() { + unset -f nvm_ls_remote nvm_ls_remote_iojs +} + +. ../../../nvm.sh + +nvm_ls_remote() { + echo "N/A" +} +OUTPUT="$(nvm_remote_version foo)" +EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A" +[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE" + +nvm_ls_remote_iojs() { + echo "N/A" +} +OUTPUT="$(nvm_remote_version iojs-foo)" +EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A" +[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE" + + +nvm_ls_remote() { + if ! nvm_is_iojs_version "$1"; then + echo "test output" + echo "more test output" + echo "pattern received: _$1_" + fi +} +nvm_ls_remote_iojs() { + if [ -z "$1" ] || nvm_is_iojs_version "$1"; then + echo "test iojs output" + echo "more iojs test output" + echo "iojs pattern received: _$1_" + fi +} +OUTPUT="$(nvm_remote_version foo)" +EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)" +[ "_$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" + +OUTPUT="$(nvm_remote_version iojs-foo)" +EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_iojs pattern received: _iojs-foo_" ] \ + || die "nvm_remote_version iojs-foo did not return last line only of nvm_ls_remote_iojs foo; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE" + +OUTPUT="$(nvm_remote_version iojs)" +EXIT_CODE="$(nvm_remote_version iojs >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_iojs pattern received: __" ] \ + || die "nvm_remote_version iojs did not return last line only of nvm_ls_remote_iojs; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs did not exit with 0, got $EXIT_CODE" + +OUTPUT="$(nvm_remote_version stable)" +EXIT_CODE="$(nvm_remote_version stable >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_$(nvm_ls_remote stable)" ] \ + || die "nvm_remote_version stable did not return contents of nvm_ls_remote stable; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version stable did not exit with 0, got $EXIT_CODE" + +OUTPUT="$(nvm_remote_version unstable)" +EXIT_CODE="$(nvm_remote_version unstable >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_$(nvm_ls_remote unstable)" ] \ + || die "nvm_remote_version unstable did not return contents of nvm_ls_remote unstable; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version unstable did not exit with 0, got $EXIT_CODE" + +OUTPUT="$(nvm_remote_version node)" +EXIT_CODE="$(nvm_remote_version node >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_$(nvm_ls_remote node)" ] \ + || die "nvm_remote_version node did not return contents of nvm_ls_remote node; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version node did not exit with 0, got $EXIT_CODE" + +cleanup diff --git a/test/fast/Unit tests/nvm_remote_versions b/test/fast/Unit tests/nvm_remote_versions new file mode 100755 index 0000000..bbbaa24 --- /dev/null +++ b/test/fast/Unit tests/nvm_remote_versions @@ -0,0 +1,78 @@ +#!/bin/sh + +die () { echo $@ ; cleanup ; exit 1; } + +cleanup() { + unset -f nvm_ls_remote nvm_ls_remote_iojs +} + +. ../../../nvm.sh + +OUTPUT="$(nvm_remote_versions stable 2>&1)" +EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions." +EXIT_CODE="$(nvm_remote_versions stable >/dev/null 2>&1; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'stable' did not error out with correct message, got $OUTPUT" +[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'stable' did not exit with code 1, got $EXIT_CODE" + +OUTPUT="$(nvm_remote_versions unstable 2>&1)" +EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions." +EXIT_CODE="$(nvm_remote_versions unstable >/dev/null 2>&1; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'unstable' did not error out with correct message, got $OUTPUT" +[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'unstable' did not exit with code 1, got $EXIT_CODE" + +nvm_ls_remote() { + echo "N/A" +} +OUTPUT="$(nvm_remote_versions foo)" +EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A" +[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE" + +nvm_ls_remote_iojs() { + echo "N/A" +} +OUTPUT="$(nvm_remote_versions iojs-foo)" +EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A" +[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE" + + +nvm_ls_remote() { + echo "test output" + echo "more test output" + echo "pattern received: _$1_" +} +nvm_ls_remote_iojs() { + echo "test iojs output" + echo "more iojs test output" + echo "iojs pattern received: _$1_" +} + +OUTPUT="$(nvm_remote_versions foo)" +EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_$(nvm_ls_remote foo) +$(nvm_ls_remote_iojs foo)" ] \ + || die "nvm_remote_versions foo did not return contents of nvm_ls_remote foo combined with nvm_ls_remote_iojs foo; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions foo did not exit with 0, got $EXIT_CODE" + +OUTPUT="$(nvm_remote_versions node)" +EXIT_CODE="$(nvm_remote_versions node >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_$(nvm_ls_remote)" ] \ + || die "nvm_remote_versions node did not return contents of nvm_ls_remote; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions node did not exit with 0, got $EXIT_CODE" + +OUTPUT="$(nvm_remote_versions iojs-foo)" +EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_$(nvm_ls_remote iojs-foo) +$(nvm_ls_remote_iojs iojs-foo)" ] \ + || die "nvm_remote_versions iojs-foo did not return contents of nvm_ls_remote iojs-foo combined with nvm_ls_remote_iojs iojs-foo; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs-foo did not exit with 0, got $EXIT_CODE" + +OUTPUT="$(nvm_remote_versions iojs)" +EXIT_CODE="$(nvm_remote_versions iojs >/dev/null 2>&1 ; echo $?)" +[ "_$OUTPUT" = "_$(nvm_ls_remote_iojs)" ] \ + || die "nvm_remote_versions iojs did not return contents of nvm_ls_remote_iojs; got $OUTPUT" +[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs did not exit with 0, got $EXIT_CODE" + +cleanup + diff --git a/test/fast/Unit tests/nvm_strip_iojs_prefix b/test/fast/Unit tests/nvm_strip_iojs_prefix new file mode 100755 index 0000000..782fbc4 --- /dev/null +++ b/test/fast/Unit tests/nvm_strip_iojs_prefix @@ -0,0 +1,10 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "_$(nvm_strip_iojs_prefix iojs)" = "_" ] || die '"nvm_strip_iojs_prefix iojs" did not return an empty string' +[ "_$(nvm_strip_iojs_prefix iojs-)" = "_" ] || die '"nvm_strip_iojs_prefix iojs-" did not return an empty string' +[ "_$(nvm_strip_iojs_prefix iojs-foo)" = "_foo" ] || die '"nvm_strip_iojs_prefix iojs-foo" did not return "foo"' +[ "_$(nvm_strip_iojs_prefix iojsfoo)" = "_iojsfoo" ] || die '"nvm_strip_iojs_prefix iojsfoo" did not return "iojsfoo"' diff --git a/test/fast/Unit tests/nvm_strip_path b/test/fast/Unit tests/nvm_strip_path new file mode 100755 index 0000000..b926cc4 --- /dev/null +++ b/test/fast/Unit tests/nvm_strip_path @@ -0,0 +1,11 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +TEST_PATH=$NVM_DIR/v0.10.5/bin:/usr/bin:$NVM_DIR/v0.11.5/bin:$NVM_DIR/v0.9.5/bin:/usr/local/bin:$NVM_DIR/v0.2.5/bin:$NVM_DIR/versions/node/v0.12.0/bin:$NVM_DIR/versions/io.js/v1.0.0/bin + +STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"` + +[ "$STRIPPED_PATH" = "/usr/bin:/usr/local/bin" ] || die "Not correctly stripped: $STRIPPED_PATH " diff --git a/test/fast/Unit tests/nvm_supports_xz b/test/fast/Unit tests/nvm_supports_xz new file mode 100755 index 0000000..5a9e4f7 --- /dev/null +++ b/test/fast/Unit tests/nvm_supports_xz @@ -0,0 +1,42 @@ +#!/bin/sh + +OLDPATH=$PATH +TEST_PATH=../../xz-test + +cleanup() { + rm -rf $TEST_PATH/{xz,which,awk,rm,command} + export PATH=$OLDPATH +} +die () { echo $@ ; cleanup ; exit 1; } + +. ../../../nvm.sh + +OLDPATH=$PATH + +mkdir -p $TEST_PATH +touch ../../xz-test/xz +chmod +x ../../xz-test/xz + +export PATH=$TEST_PATH:$PATH + +$(nvm_supports_xz "v2.3.2") || \ + die "expected 'nvm_supports_xz v2.3.2' to exit with 0" + +$(nvm_supports_xz "v0.12.7") && \ + die "expected 'nvm_supports_xz v0.12.7' to exit with 1" + + +# set up for a failure by having a minimal toolset available +# but remove xz +ln -s /usr/bin/which $TEST_PATH/which +ln -s /usr/bin/command $TEST_PATH/command +ln -s /usr/bin/awk $TEST_PATH/awk +ln -s $(which rm) $TEST_PATH/rm + +export PATH=$TEST_PATH +rm $TEST_PATH/xz + +$(nvm_supports_xz "v2.3.2") && \ + die "expected 'nvm_supports_xz v2.3.2' with a missing xz binary to exit with 1" + +cleanup diff --git a/test/fast/Unit tests/nvm_tree_contains_path b/test/fast/Unit tests/nvm_tree_contains_path new file mode 100755 index 0000000..a4ca09e --- /dev/null +++ b/test/fast/Unit tests/nvm_tree_contains_path @@ -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 + diff --git a/test/fast/Unit tests/nvm_validate_implicit_alias b/test/fast/Unit tests/nvm_validate_implicit_alias new file mode 100755 index 0000000..979f8fb --- /dev/null +++ b/test/fast/Unit tests/nvm_validate_implicit_alias @@ -0,0 +1,21 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +EXPECTED_MSG="Only implicit aliases 'stable', 'unstable', 'iojs', and 'node' are supported." +[ "_$(nvm_validate_implicit_alias 2>&1)" = "_$EXPECTED_MSG" ] \ + || die "nvm_validate_implicit_alias did not require stable|unstable|iojs|node" +[ "_$(nvm_validate_implicit_alias foo 2>&1)" = "_$EXPECTED_MSG" ] \ + || die "nvm_validate_implicit_alias did not require stable|unstable|iojs|node" + +EXIT_CODE="$(nvm_validate_implicit_alias >/dev/null 2>&1 ; echo $?)" +[ "_$EXIT_CODE" = "_1" ] \ + || die "nvm_validate_implicit_alias without stable|unstable|iojs|node 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" +nvm_validate_implicit_alias node || die "nvm_validate_implicit_alias node did not exit 0" +nvm_validate_implicit_alias iojs || die "nvm_validate_implicit_alias iojs did not exit 0" + diff --git a/test/fast/Unit tests/nvm_version b/test/fast/Unit tests/nvm_version new file mode 100755 index 0000000..4d5063b --- /dev/null +++ b/test/fast/Unit tests/nvm_version @@ -0,0 +1,48 @@ +#!/bin/sh + +die () { echo $@ ; cleanup ; exit 1; } +cleanup () { + unset -f nvm_ls_current nvm_ls +} + +. ../../../nvm.sh + +nvm_ls_current() { + echo "CURRENT!" + return 7 +} + +OUTPUT="$(nvm_version current)" +EXPECTED_OUTPUT="CURRENT!" +EXIT_CODE="$(nvm_version current 2>&1 >/dev/null ; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version current" did not return nvm_ls_current output' +[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version current" did not return nvm_ls_current exit code' + +OUTPUT="$(nvm_version)" +EXPECTED_OUTPUT="CURRENT!" +EXIT_CODE="$(nvm_version 2>&1 >/dev/null ; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return nvm_ls_current output' +[ "_$EXIT_CODE" = "_7" ] || die '"nvm_version" did not return nvm_ls_current exit code' + +nvm_ls() { + echo "line 1" + echo "line 2" + echo "pattern: $1" +} +[ "_$(nvm_version foo)" = "_pattern: foo" ] || die '"nvm_version foo" did not pass the pattern to "nvm_ls", or return the last line' +[ "_$(nvm_version node)" = "_pattern: stable" ] || die '"nvm_version node" did not pass "stable" to "nvm_ls"' +[ "_$(nvm_version node-)" = "_pattern: stable" ] || die '"nvm_version node-" did not pass "stable" to "nvm_ls"' + +nvm_ls() { echo "N/A"; } +OUTPUT="$(nvm_version foo)" +EXPECTED_OUTPUT="N/A" +EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns N/A' +[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3' + +nvm_ls() { echo; } +OUTPUT="$(nvm_version foo)" +EXPECTED_OUTPUT="N/A" +EXIT_CODE="$(nvm_version foo 2>&1 >/dev/null ; echo $?)" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die '"nvm_version" did not return N/A when nvm_ls returns nothing' +[ "_$EXIT_CODE" = "_3" ] || die '"nvm_version" returning N/A did not exit code with code 3' diff --git a/test/fast/Unit tests/nvm_version_dir b/test/fast/Unit tests/nvm_version_dir new file mode 100755 index 0000000..6fc880a --- /dev/null +++ b/test/fast/Unit tests/nvm_version_dir @@ -0,0 +1,12 @@ +#!/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 iojs)" = "$NVM_DIR/versions/io.js" ] || die '"nvm_version_dir iojs" did not return iojs dir path' +[ "$(nvm_version_dir new)" = "$(nvm_version_dir)" ] || die '"nvm_version_dir new" did not return new dir path' +[ "$(nvm_version_dir old)" = "$NVM_DIR" ] || die '"nvm_version_dir old" did not return old dir path' +[ "$(nvm_version_dir foo 2>&1)" = "unknown version dir" ] || die '"nvm_version_dir foo" did not error out' + diff --git a/test/fast/Unit tests/nvm_version_greater b/test/fast/Unit tests/nvm_version_greater new file mode 100755 index 0000000..63f5800 --- /dev/null +++ b/test/fast/Unit tests/nvm_version_greater @@ -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 + diff --git a/test/fast/Unit tests/nvm_version_path b/test/fast/Unit tests/nvm_version_path new file mode 100755 index 0000000..547ceb8 --- /dev/null +++ b/test/fast/Unit tests/nvm_version_path @@ -0,0 +1,12 @@ +#!/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' +[ "$(nvm_version_path iojs-v0.12.0)" = "$NVM_DIR/versions/io.js/v0.12.0" ] || die 'iojs version has the wrong path' + diff --git a/test/fast/setup b/test/fast/setup new file mode 100755 index 0000000..f98394b --- /dev/null +++ b/test/fast/setup @@ -0,0 +1,12 @@ +#!/bin/sh + +( + cd ../.. + + # Back up + + type setopt >/dev/null 2>&1 && setopt NULL_GLOB + type shopt >/dev/null 2>&1 && shopt -s nullglob + rm -Rf v* src alias + mkdir src alias +) diff --git a/test/fast/setup_dir b/test/fast/setup_dir new file mode 100755 index 0000000..5e2a208 --- /dev/null +++ b/test/fast/setup_dir @@ -0,0 +1,16 @@ +#!/bin/sh + +( + cd ../.. + + # Back up + + mkdir -p bak + for SRC in v* src alias; do + [ -e "$SRC" ] && mv "$SRC" bak + done + if [ -d versions ]; then + mv versions bak + fi + true +) diff --git a/test/fast/teardown b/test/fast/teardown new file mode 100755 index 0000000..a1c73df --- /dev/null +++ b/test/fast/teardown @@ -0,0 +1,10 @@ +#!/bin/sh + +# Remove temporary files +( + cd ../.. + + type setopt >/dev/null 2>&1 && setopt NULL_GLOB + type shopt >/dev/null 2>&1 && shopt -s nullglob + rm -fR v* src alias test/test-xz +) diff --git a/test/fast/teardown_dir b/test/fast/teardown_dir new file mode 100755 index 0000000..065269a --- /dev/null +++ b/test/fast/teardown_dir @@ -0,0 +1,13 @@ +#!/bin/sh + +( + cd ../.. + + # Restore + if [ -d bak ] + then + mv bak/* . > /dev/null 2>&1 || sleep 0s + rmdir bak + fi + mkdir -p src alias +) diff --git a/test/install_script/nvm_check_global_modules b/test/install_script/nvm_check_global_modules new file mode 100755 index 0000000..c57d672 --- /dev/null +++ b/test/install_script/nvm_check_global_modules @@ -0,0 +1,54 @@ +#!/bin/sh + +cleanup () { + rm -rf "$npm_config_prefix/lib" >/dev/null 2>&1 + unset npm_config_prefix + + rm -f npm + PATH="$ORIGINAL_PATH" + + unset -f setup cleanup die + unset message ORIGINAL_PATH +} +die () { echo $@ ; cleanup ; exit 1; } + +NVM_ENV=testing . ../../install.sh + +setup () { + ORIGINAL_PATH="$PATH" + + npm_config_prefix="$(pwd)" + export npm_config_prefix + mkdir -p "$npm_config_prefix/lib" +} + + +setup + +npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package' +message=$(nvm_check_global_modules) +[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed" + +npm uninstall -g nop >/dev/null +message=$(nvm_check_global_modules) +[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed" + +# Faking an installation of npm +mkdir -p "$npm_config_prefix/lib/node_modules/npm" +cat <<'JSON' >"$npm_config_prefix/lib/node_modules/npm/package.json" +{ "name": "npm", "version": "0.0.1fake" } +JSON + +message=$(nvm_check_global_modules) +[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm had only itself installed as a global module" + +# Faking the absence of npm +PATH=".:$PATH" +touch npm +chmod +x npm + +message=$(nvm_check_global_modules) +[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm was unavailable" + + +cleanup diff --git a/test/install_script/nvm_detect_profile b/test/install_script/nvm_detect_profile new file mode 100755 index 0000000..92da1d2 --- /dev/null +++ b/test/install_script/nvm_detect_profile @@ -0,0 +1,111 @@ +#!/bin/sh + +setup () { + HOME="." + NVM_ENV=testing . ../../install.sh + touch ".bashrc" + touch ".bash_profile" + touch ".zshrc" + touch ".profile" + touch "test_profile" +} + +cleanup () { + unset HOME + unset NVM_ENV + unset NVM_DETECT_PROFILE + unset -f setup cleanup die + rm -f ".bashrc" ".bash_profile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1 +} + +die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; } + +setup + +# +# Confirm profile detection via $SHELL works and that $PROFILE overrides profile detection +# + +# .bashrc should be detected for bash +NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; unset PROFILE; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then + die "nvm_detect_profile didn't pick \$HOME/.bashrc for bash" +fi + +# $PROFILE should override .bashrc profile detection +NVM_DETECT_PROFILE="$(SHELL="/bin/bash"; PROFILE="test_profile"; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then + die "nvm_detect_profile ignored \$PROFILE" +fi + +# .zshrc should be detected for zsh +NVM_DETECT_PROFILE="$(SHELL="/usr/bin/zsh"; unset PROFILE; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then + die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh" +fi + +# $PROFILE should override .zshrc profile detection +NVM_DETECT_PROFILE="$(SHELL="/usr/bin/zsh"; PROFILE="test_profile"; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then + die "nvm_detect_profile ignored \$PROFILE" +fi + + +# +# Confirm $PROFILE is only returned when it points to a valid file +# + +# $PROFILE is a valid file +NVM_DETECT_PROFILE="$(PROFILE="test_profile"; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then + die "nvm_detect_profile didn't pick \$PROFILE when it was a valid file" +fi + +# $PROFILE is not a valid file +rm "test_profile" +NVM_DETECT_PROFILE="$(PROFILE="test_profile"; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" = "test_profile" ]; then + die "nvm_detect_profile picked \$PROFILE when it was an invalid file" +fi + +# +# When profile detection fails via both $PROFILE and $SHELL, profile detection should select based on the existence of +# one of the following files is the following order: .profile, .bashrc, .bash_profile, .zshrc and +# return an empty value if everything fails +# + +# It should favor .profile if file exists +NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "$HOME/.profile" ]; then + die "nvm_detect_profile should have selected .profile" +fi + +# Otherwise, it should favor .bashrc if file exists +rm ".profile" +NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "$HOME/.bashrc" ]; then + die "nvm_detect_profile should have selected .bashrc" +fi + +# Otherwise, it should favor .bash_profile if file exists +rm ".bashrc" +NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then + die "nvm_detect_profile should have selected .bash_profile" +fi + +# Otherwise, it should favor .zshrc if file exists +rm ".bash_profile" +NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)" +if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then + die "nvm_detect_profile should have selected .zshrc" +fi + +# It should be empty if none is found +rm ".zshrc" +NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)" +if [ ! -z "$NVM_DETECT_PROFILE" ]; then + die "nvm_detect_profile should have returned an empty value" +fi + +cleanup diff --git a/test/install_script/nvm_do_install b/test/install_script/nvm_do_install new file mode 100755 index 0000000..a969602 --- /dev/null +++ b/test/install_script/nvm_do_install @@ -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' + diff --git a/test/install_script/nvm_reset b/test/install_script/nvm_reset new file mode 100755 index 0000000..9f8735a --- /dev/null +++ b/test/install_script/nvm_reset @@ -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 || die 'nvm_reset failed' + +# 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 + diff --git a/test/install_script/nvm_source b/test/install_script/nvm_source new file mode 100755 index 0000000..8307639 --- /dev/null +++ b/test/install_script/nvm_source @@ -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 + diff --git a/test/installation/io.js/install already installed uses it b/test/installation/io.js/install already installed uses it new file mode 100755 index 0000000..07e5487 --- /dev/null +++ b/test/installation/io.js/install already installed uses it @@ -0,0 +1,26 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message" + +# Remove the stuff we're clobbering. +[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0 +[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1 + +# Install from binary +nvm install iojs-v1.0.0 +nvm install iojs-v1.0.1 + +nvm use iojs-v1.0.0 + +node --version | grep v1.0.0 || die "precondition failed: iojs node doesn't start at v1.0.0" +iojs --version | grep v1.0.0 || die "precondition failed: iojs binary doesn't start at v1.0.0" + +nvm install iojs-v1.0.1 + +node --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (node binary)" +iojs --version | grep v1.0.1 || die "nvm install on already installed version doesn't use it (iojs binary)" + diff --git a/test/installation/io.js/install from binary b/test/installation/io.js/install from binary new file mode 100755 index 0000000..12cf963 --- /dev/null +++ b/test/installation/io.js/install from binary @@ -0,0 +1,19 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +NVM_TEST_VERSION="v1.0.0" +NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION" + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from binary +nvm install $NVM_PREFIXED_TEST_VERSION || die "install $NVM_PREFIXED_TEST_VERSION failed" + +# Check +[ -d ../../../versions/io.js/$NVM_TEST_VERSION ] +nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed" + diff --git a/test/installation/io.js/install two versions and use the latest one b/test/installation/io.js/install two versions and use the latest one new file mode 100755 index 0000000..7b60d74 --- /dev/null +++ b/test/installation/io.js/install two versions and use the latest one @@ -0,0 +1,26 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +# Remove the stuff we're clobbering. +[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0 +[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1 + +# Install from binary +nvm install iojs-v1.0.0 || die "'nvm install iojs-v1.0.0' failed" +nvm i iojs-v1.0.1 || die "'nvm i iojs-v1.0.1' failed" + +# Check +[ -d ../../../versions/io.js/v1.0.0 ] || die "iojs v1.0.0 didn't exist" +[ -d ../../../versions/io.js/v1.0.1 ] || die "iojs v1.0.1 didn't exist" + +# Use the first one +nvm use iojs-1.0.0 || die "'nvm use iojs-1.0.0' failed" + +# Use the latest one +nvm use iojs-1 || die "'nvm use iojs-1' failed" +[ "_$(node --version)" = "_v1.0.1" ] || die "'node --version' was not v1.0.1, got: $(node --version)" +[ "_$(iojs --version)" = "_v1.0.1" ] || die "'iojs --version' was not v1.0.1, got: $(iojs --version)" + diff --git a/test/installation/io.js/install version specified in .nvmrc from binary b/test/installation/io.js/install version specified in .nvmrc from binary new file mode 100755 index 0000000..dfab909 --- /dev/null +++ b/test/installation/io.js/install version specified in .nvmrc from binary @@ -0,0 +1,24 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +NVM_TEST_VERSION=v1.0.0 +NVM_PREFIXED_TEST_VERSION="iojs-$NVM_TEST_VERSION" +VERSION_PATH="../../../versions/io.js/$NVM_TEST_VERSION" + +# Remove the stuff we're clobbering. +[ -e $VERSION_PATH ] && rm -R $VERSION_PATH + +# Install from binary +echo "$NVM_PREFIXED_TEST_VERSION" > .nvmrc + +nvm install || die "'nvm install' failed" + +# Check +[ -d $VERSION_PATH ] || die "./$VERSION_PATH did not exist" +nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION \ + || "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed" + + diff --git a/test/installation/io.js/install while reinstalling packages b/test/installation/io.js/install while reinstalling packages new file mode 100755 index 0000000..ebbb64a --- /dev/null +++ b/test/installation/io.js/install while reinstalling packages @@ -0,0 +1,32 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +# Remove the stuff we're clobbering. +[ -e ../../../versions/io.js/v1.0.0 ] && rm -R ../../../versions/io.js/v1.0.0 +[ -e ../../../versions/io.js/v1.0.1 ] && rm -R ../../../versions/io.js/v1.0.1 + +# Install from binary +nvm install iojs-v1.0.0 + +# Check +[ -d ../../../versions/io.js/v1.0.0 ] || die "nvm install iojs-v1.0.0 didn't install" + +node --version | grep v1.0.0 > /dev/null || die "nvm install didn't use iojs-v1.0.0" + +npm install -g object-is@0.0.0 || die "npm install -g object-is failed" +npm list --global | grep object-is > /dev/null || die "object-is isn't installed" + +nvm ls iojs-1 | grep iojs-v1.0.0 > /dev/null || die "nvm ls iojs-1 didn't show iojs-v1.0.0" + +nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 || die "nvm install iojs-v1.0.1 --reinstall-packages-from=iojs-1.0.0 failed" + +[ -d ../../../versions/io.js/v1.0.1 ] || die "nvm install iojs-v1.0.1 didn't install" + +nvm use iojs-1 +node --version | grep v1.0.1 > /dev/null || die "nvm use iojs-1 didn't use v1.0.1" + +npm list --global | grep object-is > /dev/null || die "object-is isn't installed" + diff --git a/test/installation/io.js/nvm install v1 works b/test/installation/io.js/nvm install v1 works new file mode 100755 index 0000000..b54d1f0 --- /dev/null +++ b/test/installation/io.js/nvm install v1 works @@ -0,0 +1,20 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +NVM_VERSION="v1" +NVM_PREFIXED_TEST_VERSION="$(nvm ls-remote "$NVM_VERSION" | tail -n1 | sed 's/^[ ]*//;s/[ ]*$//')" +NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")" + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from binary +nvm install "$NVM_VERSION" || die "nvm install $NVM_VERSION failed" + +# Check +[ -d ../../../versions/io.js/$NVM_TEST_VERSION ] +nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed" + diff --git a/test/installation/io.js/setup_dir b/test/installation/io.js/setup_dir new file mode 100755 index 0000000..50dc4e4 --- /dev/null +++ b/test/installation/io.js/setup_dir @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ -f ".nvmrc" ]; then + mv .nvmrc .nvmrc.bak +fi + diff --git a/test/installation/io.js/teardown_dir b/test/installation/io.js/teardown_dir new file mode 100755 index 0000000..a7e6f3e --- /dev/null +++ b/test/installation/io.js/teardown_dir @@ -0,0 +1,14 @@ +#!/bin/sh + +. ../../../nvm.sh +nvm deactivate +nvm uninstall iojs-v1.0.0 + +if [ -f ".nvmrc" ]; then + rm .nvmrc +fi + +if [ -f ".nvmrc.bak" ]; then + mv .nvmrc.bak .nvmrc +fi + diff --git a/test/installation/node/install already installed uses it b/test/installation/node/install already installed uses it new file mode 100755 index 0000000..ffcbb02 --- /dev/null +++ b/test/installation/node/install already installed uses it @@ -0,0 +1,24 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message" + +# Remove the stuff we're clobbering. +[ -e ../../../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 + +nvm use 0.9.7 + +node --version | grep v0.9.7 || die "precondition failed: node doesn't start at 0.9.7" + +nvm install 0.9.12 + +node --version | grep v0.9.12 || die "nvm install on already installed version doesn't use it" + diff --git a/test/installation/node/install from binary b/test/installation/node/install from binary new file mode 100755 index 0000000..3e17e8e --- /dev/null +++ b/test/installation/node/install from binary @@ -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" + diff --git a/test/installation/node/install from source b/test/installation/node/install from source new file mode 100755 index 0000000..3cf0389 --- /dev/null +++ b/test/installation/node/install from source @@ -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" + diff --git a/test/installation/node/install from source implicitly b/test/installation/node/install from source implicitly new file mode 100755 index 0000000..924c1f8 --- /dev/null +++ b/test/installation/node/install from source implicitly @@ -0,0 +1,18 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +NVM_TEST_VERSION=v0.8.5 + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from source implicitly (v0.8.6 is when binaries started) +nvm install $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" + diff --git a/test/installation/node/install from source with thread parameter b/test/installation/node/install from source with thread parameter new file mode 100755 index 0000000..84af8ad --- /dev/null +++ b/test/installation/node/install from source with thread parameter @@ -0,0 +1,33 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +NVM_TEST_VERSION=v0.10.41 + +# STAGE 1 # + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from source with 1 make job +nvm install -s -j 1 $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" + + + +# STAGE 2 # + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from source with 2 make jobs (and swapped arg order) +nvm install -j 2 -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" diff --git a/test/installation/node/install from source without V8 snapshot for ARM b/test/installation/node/install from source without V8 snapshot for ARM new file mode 100755 index 0000000..3755d71 --- /dev/null +++ b/test/installation/node/install from source without V8 snapshot for ARM @@ -0,0 +1,25 @@ +#!/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 + +# Fake ARM arch +nvm_get_arch() { + echo "armv7l" +} + +# Install from source +nvm install -s $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed" + +# Check Install +[ -d ../../../$NVM_TEST_VERSION ] +node --version | grep $NVM_TEST_VERSION || "'node --version | grep $NVM_TEST_VERSION' failed" + +# Check V8 snapshot isn't compiled +node -p "if(! process.config.variables.v8_use_snapshot) { console.log('no-snapshot'); }" | grep "no-snapshot" || "'node -p \"if(! process.config.variables.v8_use_snapshot) { console.log('no-snapshot'); }\" | grep \"no-snapshot\"' failed" \ No newline at end of file diff --git a/test/installation/node/install two versions and use the latest one b/test/installation/node/install two versions and use the latest one new file mode 100755 index 0000000..1fedace --- /dev/null +++ b/test/installation/node/install two versions and use the latest one @@ -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)" + diff --git a/test/installation/node/install version specified in .nvmrc from binary b/test/installation/node/install version specified in .nvmrc from binary new file mode 100755 index 0000000..859a199 --- /dev/null +++ b/test/installation/node/install version specified in .nvmrc from binary @@ -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" + + diff --git a/test/installation/node/install version specified in .nvmrc from source b/test/installation/node/install version specified in .nvmrc from source new file mode 100755 index 0000000..6952645 --- /dev/null +++ b/test/installation/node/install version specified in .nvmrc from source @@ -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" + + diff --git a/test/installation/node/install while reinstalling packages b/test/installation/node/install while reinstalling packages new file mode 100755 index 0000000..c170a10 --- /dev/null +++ b/test/installation/node/install while reinstalling packages @@ -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 object-is@0.0.0 || die "npm install -g object-is failed" +npm list --global | grep object-is > /dev/null || die "object-is 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 object-is > /dev/null || die "object-is isn't installed" + diff --git a/test/installation/node/setup_dir b/test/installation/node/setup_dir new file mode 100755 index 0000000..50dc4e4 --- /dev/null +++ b/test/installation/node/setup_dir @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ -f ".nvmrc" ]; then + mv .nvmrc .nvmrc.bak +fi + diff --git a/test/installation/node/teardown_dir b/test/installation/node/teardown_dir new file mode 100755 index 0000000..8285de3 --- /dev/null +++ b/test/installation/node/teardown_dir @@ -0,0 +1,14 @@ +#!/bin/sh + +. ../../../nvm.sh +nvm deactivate +nvm uninstall v0.10.7 + +if [ -f ".nvmrc" ]; then + rm .nvmrc +fi + +if [ -f ".nvmrc.bak" ]; then + mv .nvmrc.bak .nvmrc +fi + diff --git a/test/mocks/isainfo_amd64 b/test/mocks/isainfo_amd64 new file mode 100755 index 0000000..37f805b --- /dev/null +++ b/test/mocks/isainfo_amd64 @@ -0,0 +1,5 @@ +if [ "_$1" = "_-n" ]; then + echo "amd64" +else + echo "amd64 i386" +fi diff --git a/test/mocks/isainfo_x86 b/test/mocks/isainfo_x86 new file mode 100755 index 0000000..4658d2a --- /dev/null +++ b/test/mocks/isainfo_x86 @@ -0,0 +1,5 @@ +if [ "_$1" = "_-n" ]; then + echo "i386" +else + echo "i386" +fi diff --git a/test/mocks/pkg_info_amd64 b/test/mocks/pkg_info_amd64 new file mode 100755 index 0000000..8437c2b --- /dev/null +++ b/test/mocks/pkg_info_amd64 @@ -0,0 +1 @@ +echo "x86_64" diff --git a/test/mocks/pkg_info_x86 b/test/mocks/pkg_info_x86 new file mode 100755 index 0000000..a555469 --- /dev/null +++ b/test/mocks/pkg_info_x86 @@ -0,0 +1 @@ +echo "i386" diff --git a/test/mocks/uname_osx_amd64 b/test/mocks/uname_osx_amd64 new file mode 100755 index 0000000..8552d1d --- /dev/null +++ b/test/mocks/uname_osx_amd64 @@ -0,0 +1,5 @@ +if [ "_$1" = "_-m" ]; then + echo "x86_64" +else + echo "Darwin foo.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64" + fi diff --git a/test/mocks/uname_osx_x86 b/test/mocks/uname_osx_x86 new file mode 100755 index 0000000..0d91a7e --- /dev/null +++ b/test/mocks/uname_osx_x86 @@ -0,0 +1,5 @@ +if [ "_$1" = "_-m" ]; then + echo "i386" +else + echo "Darwin foo.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_I386 i386" + fi diff --git a/test/mocks/uname_smartos_amd64 b/test/mocks/uname_smartos_amd64 new file mode 100755 index 0000000..452f3bc --- /dev/null +++ b/test/mocks/uname_smartos_amd64 @@ -0,0 +1,5 @@ +if [ "_$1" = "_-m" ]; then + echo "i86pc" +else + echo "SunOS dev 5.11 joyent_20150219T102159Z i86pc i386 i86pc Solaris" +fi diff --git a/test/mocks/uname_smartos_x86 b/test/mocks/uname_smartos_x86 new file mode 100755 index 0000000..452f3bc --- /dev/null +++ b/test/mocks/uname_smartos_x86 @@ -0,0 +1,5 @@ +if [ "_$1" = "_-m" ]; then + echo "i86pc" +else + echo "SunOS dev 5.11 joyent_20150219T102159Z i86pc i386 i86pc Solaris" +fi diff --git "a/test/slow/Running \"nvm current\" should display current nvm environment." "b/test/slow/Running \"nvm current\" should display current nvm environment." new file mode 100755 index 0000000..05082e3 --- /dev/null +++ "b/test/slow/Running \"nvm current\" should display current nvm environment." @@ -0,0 +1,9 @@ +#!/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)\"" diff --git a/test/slow/node 0.6.21 should install 0.6.21-pre b/test/slow/node 0.6.21 should install 0.6.21-pre new file mode 100755 index 0000000..93afff7 --- /dev/null +++ b/test/slow/node 0.6.21 should install 0.6.21-pre @@ -0,0 +1,10 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../nvm.sh + +nvm install 0.6.21 || die 'v0.6.21 installation failed' +[ "_$(node -v)" = "_v0.6.21-pre" ] || die "v0.6.21-pre not installed with v0.6.21, got $(node -v)" +[ "_$(nvm current)" = "_v0.6.21" ] || die "v0.6.21-pre not reported as v0.6.21, got $(nvm current)" + diff --git "a/test/slow/nvm exec/Running \"nvm exec 0.x\" should work" "b/test/slow/nvm exec/Running \"nvm exec 0.x\" should work" new file mode 100755 index 0000000..bf036cf --- /dev/null +++ "b/test/slow/nvm exec/Running \"nvm exec 0.x\" should work" @@ -0,0 +1,15 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm use 0.10 +NPM_VERSION_TEN="$(npm --version)" +TEST_STRING="foo bar" + +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" + +[ "$(nvm exec 0.10 bash -c "printf '$TEST_STRING'" | tail -1)" = "$TEST_STRING" ] || die "`nvm exec` failed to run with the command include white-spaces" diff --git "a/test/slow/nvm exec/Running \"nvm exec\" should pick up .nvmrc version" "b/test/slow/nvm exec/Running \"nvm exec\" should pick up .nvmrc version" new file mode 100755 index 0000000..203cd9a --- /dev/null +++ "b/test/slow/nvm exec/Running \"nvm exec\" should pick up .nvmrc version" @@ -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" + diff --git a/test/slow/nvm exec/setup_dir b/test/slow/nvm exec/setup_dir new file mode 100755 index 0000000..a5fc4bc --- /dev/null +++ b/test/slow/nvm exec/setup_dir @@ -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 + diff --git a/test/slow/nvm exec/teardown_dir b/test/slow/nvm exec/teardown_dir new file mode 100755 index 0000000..789456c --- /dev/null +++ b/test/slow/nvm exec/teardown_dir @@ -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 + diff --git "a/test/slow/nvm reinstall-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" "b/test/slow/nvm reinstall-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" new file mode 100755 index 0000000..1951b12 --- /dev/null +++ "b/test/slow/nvm reinstall-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" @@ -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'" + diff --git a/test/slow/nvm reinstall-packages/setup_dir b/test/slow/nvm reinstall-packages/setup_dir new file mode 100755 index 0000000..c550f69 --- /dev/null +++ b/test/slow/nvm reinstall-packages/setup_dir @@ -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 + diff --git a/test/slow/nvm reinstall-packages/should work as expected b/test/slow/nvm reinstall-packages/should work as expected new file mode 100755 index 0000000..e0156d4 --- /dev/null +++ b/test/slow/nvm reinstall-packages/should work as expected @@ -0,0 +1,30 @@ +#!/bin/sh + +die () { echo "$@" ; exit 1; } + +. ../../../nvm.sh + +nvm exec 0.10.28 npm install -g npm@~1.4.11 # this is required because before 1.4.10, npm ls doesn't indicated linked packages +nvm exec 0.10.29 npm install -g npm@~1.4.11 # this is required because before 1.4.10, npm ls doesn't indicated linked packages + +nvm use 0.10.28 +(cd test-npmlink && npm link) + +EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame spawn-sync test-npmlink uglify-js yo" + +echo "$EXPECTED_PACKAGES" | sed -e 's/test-npmlink //' | xargs npm install -g --quiet + +get_packages() { + npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs +} + +nvm use 0.10.29 +ORIGINAL_PACKAGES=$(get_packages) + +nvm reinstall-packages 0.10.28 +FINAL_PACKAGES=$(get_packages) + +[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)" +[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)" + +[ $(test-npmlink) = 'ok' ] || die "failed to run test-npmlink" diff --git a/test/slow/nvm reinstall-packages/teardown_dir b/test/slow/nvm reinstall-packages/teardown_dir new file mode 100755 index 0000000..1282eb4 --- /dev/null +++ b/test/slow/nvm reinstall-packages/teardown_dir @@ -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 + diff --git a/test/slow/nvm reinstall-packages/test-npmlink/index.js b/test/slow/nvm reinstall-packages/test-npmlink/index.js new file mode 100755 index 0000000..9558516 --- /dev/null +++ b/test/slow/nvm reinstall-packages/test-npmlink/index.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +console.log('ok') diff --git a/test/slow/nvm reinstall-packages/test-npmlink/package.json b/test/slow/nvm reinstall-packages/test-npmlink/package.json new file mode 100644 index 0000000..e596ea4 --- /dev/null +++ b/test/slow/nvm reinstall-packages/test-npmlink/package.json @@ -0,0 +1,10 @@ +{ + "name": "test-npmlink", + "version": "0.0.1", + "description": "Stub package for testing npm link", + "bin": { + "test-npmlink": "index.js" + }, + "author": "hax", + "license": "ISC" +} diff --git "a/test/slow/nvm run/Running \"nvm run --harmony --version\" should work" "b/test/slow/nvm run/Running \"nvm run --harmony --version\" should work" new file mode 100755 index 0000000..dfb90a9 --- /dev/null +++ "b/test/slow/nvm run/Running \"nvm run --harmony --version\" should work" @@ -0,0 +1,9 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm run 0.10.7 --harmony --version +[ "_$(nvm run 0.10.7 --harmony --version 2>/dev/null | tail -1)" = "_v0.10.7" ] || die "\`nvm run --harmony --version\` failed to run with the correct version" + diff --git "a/test/slow/nvm run/Running \"nvm run 0.x\" should error out sensibly when 0.x is not installed" "b/test/slow/nvm run/Running \"nvm run 0.x\" should error out sensibly when 0.x is not installed" new file mode 100755 index 0000000..bde5867 --- /dev/null +++ "b/test/slow/nvm run/Running \"nvm run 0.x\" should error out sensibly when 0.x is not installed" @@ -0,0 +1,9 @@ +#!/bin/sh + + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "$(nvm run 0.2 --version 2>&1)" = 'N/A: version "v0.2" is not yet installed' ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly" +[ "$(nvm run iojs-0.2 --version 2>&1)" = 'N/A: version "iojs-v0.2" is not yet installed' ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly" diff --git "a/test/slow/nvm run/Running \"nvm run 0.x\" should work" "b/test/slow/nvm run/Running \"nvm run 0.x\" should work" new file mode 100755 index 0000000..9bcf97f --- /dev/null +++ "b/test/slow/nvm run/Running \"nvm run 0.x\" should work" @@ -0,0 +1,9 @@ +#!/bin/sh + + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "$(nvm run 0.10.7 --version | tail -1)" = "v0.10.7" ] || die "\`nvm run\` failed to run with the correct version" + diff --git "a/test/slow/nvm run/Running \"nvm run\" should pick up .nvmrc version" "b/test/slow/nvm run/Running \"nvm run\" should pick up .nvmrc version" new file mode 100755 index 0000000..d462488 --- /dev/null +++ "b/test/slow/nvm run/Running \"nvm run\" should pick up .nvmrc version" @@ -0,0 +1,13 @@ +#!/bin/sh + + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +echo "0.10.7" > .nvmrc + +[ "$(nvm run --version | tail -1)" = "v0.10.7" ] || die "\`nvm run\` failed to run with the .nvmrc version" + +[ "$(nvm run --version | head -1)" = "Found '$PWD/.nvmrc' with version <0.10.7>" ] || die "\`nvm run\` failed to print out the \"found in .nvmrc\" message" + diff --git a/test/slow/nvm run/setup_dir b/test/slow/nvm run/setup_dir new file mode 100755 index 0000000..870a22c --- /dev/null +++ b/test/slow/nvm run/setup_dir @@ -0,0 +1,9 @@ +#!/bin/sh + +. ../../../nvm.sh +nvm install 0.10.7 + +if [ -f ".nvmrc" ]; then + mv .nvmrc .nvmrc.bak +fi + diff --git a/test/slow/nvm run/teardown_dir b/test/slow/nvm run/teardown_dir new file mode 100755 index 0000000..55e2a61 --- /dev/null +++ b/test/slow/nvm run/teardown_dir @@ -0,0 +1,12 @@ +#!/bin/sh + +. ../../../nvm.sh +nvm deactivate +nvm uninstall v0.10.7 + +rm .nvmrc + +if [ -f ".nvmrc.bak" ]; then + mv .nvmrc.bak .nvmrc +fi + diff --git "a/test/slow/nvm use/Running \"nvm use iojs\" uses latest io.js version" "b/test/slow/nvm use/Running \"nvm use iojs\" uses latest io.js version" new file mode 100755 index 0000000..506ff86 --- /dev/null +++ "b/test/slow/nvm use/Running \"nvm use iojs\" uses latest io.js version" @@ -0,0 +1,20 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm deactivate 2>&1 >/dev/null || die 'deactivate failed' + +nvm use iojs || die 'nvm use iojs failed' +OUTPUT="$(nvm current)" +EXPECTED_OUTPUT="iojs-v1.0.1" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use iojs' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" + +OUTPUT="$(nvm use --silent iojs)" +EXPECTED_OUTPUT="" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use --silent iojs' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'" diff --git "a/test/slow/nvm use/Running \"nvm use node\" uses latest stable node version" "b/test/slow/nvm use/Running \"nvm use node\" uses latest stable node version" new file mode 100755 index 0000000..ce84bb6 --- /dev/null +++ "b/test/slow/nvm use/Running \"nvm use node\" uses latest stable node version" @@ -0,0 +1,20 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm deactivate 2>&1 >/dev/null || die 'deactivate failed' + +nvm use node || die 'nvm use node failed' +OUTPUT="$(nvm current)" +EXPECTED_OUTPUT="$(nvm_version stable)" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use node' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" + +OUTPUT="$(nvm use --silent node)" +EXPECTED_OUTPUT="" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use --silent node' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'" diff --git "a/test/slow/nvm use/Running \"nvm use v1.0.0\" uses iojs-v1.0.0 iojs version" "b/test/slow/nvm use/Running \"nvm use v1.0.0\" uses iojs-v1.0.0 iojs version" new file mode 100755 index 0000000..2416c79 --- /dev/null +++ "b/test/slow/nvm use/Running \"nvm use v1.0.0\" uses iojs-v1.0.0 iojs version" @@ -0,0 +1,20 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm deactivate 2>&1 >/dev/null || die 'deactivate failed' + +nvm use 'v1.0.0' || die 'nvm use v1.0.0 failed' +OUTPUT="$(nvm current)" +EXPECTED_OUTPUT="$(nvm_version v1.0.0)" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" + +OUTPUT="$(nvm use --silent 'v1.0.0')" +EXPECTED_OUTPUT="" + +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use --silent v1.0.0' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'" diff --git "a/test/slow/nvm use/Running \"nvm use\" calls \"nvm_die_on_prefix\"" "b/test/slow/nvm use/Running \"nvm use\" calls \"nvm_die_on_prefix\"" new file mode 100755 index 0000000..faf9644 --- /dev/null +++ "b/test/slow/nvm use/Running \"nvm use\" calls \"nvm_die_on_prefix\"" @@ -0,0 +1,22 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm deactivate >/dev/null 2>&1 || die 'deactivate failed' + +nvm_die_on_prefix() { + echo >&2 "| $1 | $2 |" + return 3 +} + +OUTPUT="$(nvm use --silent node)" +EXPECTED_OUTPUT="" +[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ + || die "'nvm use --silent node' did not call through to 'nvm_die_on_prefix' and give output '$EXPECTED_OUTPUT'; got '$OUTPUT'" + +EXIT_CODE="$(nvm use --silent node >/dev/null 2>&1; echo $?)" +EXPECTED_CODE="11" +[ "_$EXIT_CODE" = "_$EXPECTED_CODE" ] \ + || die "'nvm use --silent node' when 'nvm_die_on_prefix' fails did not return '$EXPECTED_CODE'; got '$EXIT_CODE'" diff --git a/test/slow/nvm use/setup_dir b/test/slow/nvm use/setup_dir new file mode 100755 index 0000000..a3ab0f7 --- /dev/null +++ b/test/slow/nvm use/setup_dir @@ -0,0 +1,16 @@ +#!/bin/sh + +. ../../../nvm.sh + +mkdir -p ../../../.nvm_use_bak +if [ -d "../../../v*" ]; then + mv "../../../v*" ../../../.nvm_use_bak/ +fi + +for VERSION in "0.8.7" "0.9.1" "0.10.1" "0.11.1"; do + nvm install "v$VERSION" +done + +for VERSION in "1.0.0" "1.0.1"; do + nvm install "iojs-v$VERSION" +done diff --git a/test/slow/nvm use/teardown_dir b/test/slow/nvm use/teardown_dir new file mode 100755 index 0000000..eeda337 --- /dev/null +++ b/test/slow/nvm use/teardown_dir @@ -0,0 +1,16 @@ +#!/bin/sh + +. ../../../nvm.sh + +for VERSION in "0.8.7" "0.9.1" "0.10.1" "0.11.1"; do + nvm uninstall "$VERSION" +done + +for VERSION in "1.0.0" "1.0.1"; do + nvm uninstall "iojs-v$VERSION" +done + +if [ -d ../../../.nvm_use_bak/* ]; then + mv ../../../.nvm_use_bak/* ../../../ +fi +rmdir ../../../.nvm_use_bak diff --git a/test/slow/nvm_get_latest/nvm_get_latest b/test/slow/nvm_get_latest/nvm_get_latest new file mode 100755 index 0000000..3348fd5 --- /dev/null +++ b/test/slow/nvm_get_latest/nvm_get_latest @@ -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="-q -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 + diff --git a/test/slow/nvm_get_latest/nvm_get_latest failed redirect b/test/slow/nvm_get_latest/nvm_get_latest failed redirect new file mode 100755 index 0000000..cc43b53 --- /dev/null +++ b/test/slow/nvm_get_latest/nvm_get_latest failed redirect @@ -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 + diff --git a/test/sourcing/Sourcing nvm.sh should use the default if available b/test/sourcing/Sourcing nvm.sh should use the default if available new file mode 100755 index 0000000..57cb839 --- /dev/null +++ b/test/sourcing/Sourcing nvm.sh should use the default if available @@ -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'" + diff --git a/test/sourcing/Sourcing nvm.sh with --install and .nvmrc should install it b/test/sourcing/Sourcing nvm.sh with --install and .nvmrc should install it new file mode 100755 index 0000000..edc5614 --- /dev/null +++ b/test/sourcing/Sourcing nvm.sh with --install and .nvmrc should install it @@ -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`" + diff --git a/test/sourcing/Sourcing nvm.sh with --install should install the default b/test/sourcing/Sourcing nvm.sh with --install should install the default new file mode 100755 index 0000000..e25ddf0 --- /dev/null +++ b/test/sourcing/Sourcing nvm.sh with --install should install the default @@ -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'" + diff --git a/test/sourcing/Sourcing nvm.sh with --no-use should not use anything b/test/sourcing/Sourcing nvm.sh with --no-use should not use anything new file mode 100755 index 0000000..c0b6533 --- /dev/null +++ b/test/sourcing/Sourcing nvm.sh with --no-use should not use anything @@ -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 + +. ../../nvm.sh +nvm install 4.1.0 || die 'install of v4.1.0 failed' +nvm_version 4.1.0 >/dev/null 2>&1 || die "v4.1.0 not installed: $(nvm ls)" +nvm deactivate || die 'nvm deactivate failed' + +NVM_CURRENT="$(nvm current)" +[ "_$NVM_CURRENT" = '_none' ] || [ "_$NVM_CURRENT" = '_system' ] || die "'nvm current' did not return 'none' or 'system', got '$NVM_CURRENT' `nvm ls`" + +nvm unload || die 'nvm unload failed' + +. ../../nvm.sh --no-use +EXIT_CODE="$(echo $?)" + +echo 'sourcing complete.' + +[ "_$EXIT_CODE" = "_0" ] || die "sourcing returned nonzero exit code: $EXIT_CODE" + +NVM_CURRENT="$(nvm current)" +[ "_$NVM_CURRENT" = '_none' ] || [ "_$NVM_CURRENT" = '_system' ] || die "'nvm current' did not return 'none' or 'system', got '$NVM_CURRENT' `nvm ls`" + diff --git a/test/sourcing/Sourcing nvm.sh with no default should return 0 b/test/sourcing/Sourcing nvm.sh with no default should return 0 new file mode 100755 index 0000000..91e149a --- /dev/null +++ b/test/sourcing/Sourcing nvm.sh with no default should return 0 @@ -0,0 +1,11 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +touch ../../alias/default +rm ../../alias/default || die 'removal of default alias failed' +nvm_alias default && die '"nvm_alias default" did not fail' + +set -e # necessary to fail internally with a nonzero code + +. ../../nvm.sh || die 'sourcing returned nonzero exit code' diff --git a/test/sourcing/setup b/test/sourcing/setup new file mode 100755 index 0000000..4d5a97b --- /dev/null +++ b/test/sourcing/setup @@ -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' + diff --git a/test/sourcing/teardown b/test/sourcing/teardown new file mode 100755 index 0000000..6a31472 --- /dev/null +++ b/test/sourcing/teardown @@ -0,0 +1,7 @@ +#!/bin/sh + +rm -rf ../../alias +rm -rf ../../v0.10.1 +rm -rf ../../v0.10.2 +rm -f ../../.nvmrc +