diff --git a/.gitignore b/.gitignore index 56fd724..f4796a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,14 @@ -HEAD -src -v* -alias - -# For testing -test/bak -.urchin.log -.urchin_stdout - -node_modules/ - -.DS_Store - +HEAD +src +v* +alias + +# For testing +test/bak +.urchin.log +.urchin_stdout + +node_modules/ + +.DS_Store + diff --git a/.npmignore b/.npmignore index 529045f..0425628 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,4 @@ -src -v* -alias - +src +v* +alias + diff --git a/.travis.yml b/.travis.yml index 36fbc86..25ce079 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,14 @@ -language: c # defaults to ruby -install: - - sudo apt-get install ksh zsh -y -before_script: - - curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin && chmod +x /tmp/urchin -script: - - NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin $SHELL -env: - - 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 +language: c # defaults to ruby +install: + - sudo apt-get install ksh zsh -y +before_script: + - curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin && chmod +x /tmp/urchin +script: + - NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin $SHELL +env: + - 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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1f07a9..a6d5842 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +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, and all tests, pass in `bash`, `sh`, and `zsh`. We hope to soon automatically run all these tests, but in the meantime, we have to rely on each contributor doing so. - - 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! - +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, and all tests, pass in `bash`, `sh`, and `zsh`. We hope to soon automatically run all these tests, but in the meantime, we have to rely on each contributor doing so. + - 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 index d79df5f..8133ffe 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2010-2014 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. - +The MIT License (MIT) + +Copyright (c) 2010-2014 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 index 67d860b..dd2901e 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ -URCHIN=`which urchin` -SHELLS=sh bash dash ksh zsh -TEST_SUITE=fast - -.PHONY: $(SHELLS) test - -$(SHELLS): - @printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@" - @$@ $(URCHIN) -f test/$(TEST_SUITE) - -test: $(SHELLS) - @$(URCHIN) -f test/slow - -default: test - +URCHIN=`which urchin` +SHELLS=sh bash dash ksh zsh +TEST_SUITE=fast + +.PHONY: $(SHELLS) test + +$(SHELLS): + @printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@" + @$@ $(URCHIN) -f test/$(TEST_SUITE) + +test: $(SHELLS) + @$(URCHIN) -f test/slow + +default: test + diff --git a/README.markdown b/README.markdown index eb82591..8a616b5 100644 --- a/README.markdown +++ b/README.markdown @@ -1,169 +1,169 @@ -# 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. - -### Install script - -To install you could use the [install script][2] using cURL: - - curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh - -or Wget: - - wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh - -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 `NVM_PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm sh` for a global install. - -*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 a folder called `nvm`. - -Or if you have `git` installed, then just clone it: - - git clone https://github.com/creationix/nvm.git ~/.nvm - -To activate nvm, you need to source it from your shell: - - source ~/.nvm/nvm.sh - -I always add this line to my `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login. -Often I also put in a line to use a specific version of node. - -## Usage - -You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory). -`nvm use`, `nvm install`, and `nvm run` will all respect an `.nvmrc` file. - -To download, compile, and install the latest v0.10.x release of node, do this: - - nvm install 0.10 - -And then in any new shell just use the installed version: - - nvm use 0.10 - -Or you can just run it: - - nvm run 0.10 --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 0.10 - -To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`: - - export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist - nvm install 0.10 - - NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 0.10 - -## License - -nvm is released under the MIT license. - - -Copyright (C) 2010-2014 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 copy-packages help list run uninstall version - clear-cache deactivate install ls unalias use - -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 - -## 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'? Checkout 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 - -[1]: https://github.com/creationix/nvm.git -[2]: https://github.com/creationix/nvm/blob/v0.7.0/install.sh -[3]: https://travis-ci.org/creationix/nvm -[Urchin]: https://github.com/scraperwiki/urchin - +# 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. + +### Install script + +To install you could use the [install script][2] using cURL: + + curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh + +or Wget: + + wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh + +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 `NVM_PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm sh` for a global install. + +*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 a folder called `nvm`. + +Or if you have `git` installed, then just clone it: + + git clone https://github.com/creationix/nvm.git ~/.nvm + +To activate nvm, you need to source it from your shell: + + source ~/.nvm/nvm.sh + +I always add this line to my `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login. +Often I also put in a line to use a specific version of node. + +## Usage + +You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory). +`nvm use`, `nvm install`, and `nvm run` will all respect an `.nvmrc` file. + +To download, compile, and install the latest v0.10.x release of node, do this: + + nvm install 0.10 + +And then in any new shell just use the installed version: + + nvm use 0.10 + +Or you can just run it: + + nvm run 0.10 --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 0.10 + +To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`: + + export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist + nvm install 0.10 + + NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 0.10 + +## License + +nvm is released under the MIT license. + + +Copyright (C) 2010-2014 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 copy-packages help list run uninstall version + clear-cache deactivate install ls unalias use + +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 + +## 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'? Checkout 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 + +[1]: https://github.com/creationix/nvm.git +[2]: https://github.com/creationix/nvm/blob/v0.7.0/install.sh +[3]: https://travis-ci.org/creationix/nvm +[Urchin]: https://github.com/scraperwiki/urchin + diff --git a/bash_completion b/bash_completion index 6f80584..b5582ca 100644 --- a/bash_completion +++ b/bash_completion @@ -1,90 +1,90 @@ -#!/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\ - ls ls-remote list list-remote deactivate\ - alias unalias copy-packages clear-cache version' - - 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 && 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|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 - +#!/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\ + ls ls-remote list list-remote deactivate\ + alias unalias copy-packages clear-cache version' + + 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 && 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|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 index 10bf9ca..7bee7b9 100755 --- a/install.sh +++ b/install.sh @@ -1,130 +1,130 @@ -#!/bin/bash - -set -e - -has() { - type "$1" > /dev/null 2>&1 - return $? -} - -if [ -z "$NVM_DIR" ]; then - NVM_DIR="$HOME/.nvm" -fi - -if ! has "curl"; then - if has "wget"; then - # Emulate curl with wget - curl() { - ARGS="$* " - ARGS=${ARGS/-s /-q } - ARGS=${ARGS/-o /-O } - wget $ARGS - } - fi -fi - -install_from_git() { - if [ -z "$NVM_SOURCE" ]; then - NVM_SOURCE="https://github.com/creationix/nvm.git" - fi - - if [ -d "$NVM_DIR/.git" ]; then - echo "=> nvm is already installed in $NVM_DIR, trying to update" - echo -e "\r=> \c" - cd "$NVM_DIR" && git pull 2> /dev/null || { - echo >&2 "Failed to update nvm, run 'git pull' in $NVM_DIR yourself.." - } - else - # Cloning to $NVM_DIR - echo "=> Downloading nvm from git to '$NVM_DIR'" - echo -e "\r=> \c" - mkdir -p "$NVM_DIR" - git clone "$NVM_SOURCE" "$NVM_DIR" - fi -} - -install_as_script() { - if [ -z "$NVM_SOURCE" ]; then - NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh" - fi - - # Downloading to $NVM_DIR - mkdir -p "$NVM_DIR" - if [ -d "$NVM_DIR/nvm.sh" ]; then - echo "=> nvm is already installed in $NVM_DIR, trying to update" - else - echo "=> Downloading nvm as script to '$NVM_DIR'" - fi - curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || { - echo >&2 "Failed to download '$NVM_SOURCE'.." - return 1 - } -} - -if [ -z "$METHOD" ]; then - # Autodetect install method - if has "git"; then - install_from_git - elif has "curl"; then - install_as_script - else - echo >&2 "You need git, curl or wget to install nvm" - exit 1 - fi -else - if [ "$METHOD" = "git" ]; then - if ! has "git"; then - echo >&2 "You need git to install nvm" - exit 1 - fi - install_from_git - fi - if [ "$METHOD" = "script" ]; then - if ! has "curl"; then - echo >&2 "You need curl or wget to install nvm" - exit 1 - fi - install_as_script - fi -fi - -echo - -# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile). -if [ -z "$PROFILE" ]; then - if [ -f "$HOME/.bash_profile" ]; then - PROFILE="$HOME/.bash_profile" - elif [ -f "$HOME/.zshrc" ]; then - PROFILE="$HOME/.zshrc" - elif [ -f "$HOME/.profile" ]; then - PROFILE="$HOME/.profile" - fi -fi - -SOURCE_STR="[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\" # This loads nvm" - -if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then - if [ -z $PROFILE ]; then - echo "=> Profile not found. Tried ~/.bash_profile ~/.zshrc and ~/.profile." - echo "=> Create one of them and run this script again" - else - echo "=> Profile $PROFILE not found" - echo "=> Create it (touch $PROFILE) and run this script again" - fi - echo " OR" - echo "=> Append the following line to the correct file yourself:" - echo - echo " $SOURCE_STR" - echo -else - if ! grep -qc 'nvm.sh' $PROFILE; then - echo "=> Appending source string to $PROFILE" - echo "" >> "$PROFILE" - echo $SOURCE_STR >> "$PROFILE" - else - echo "=> Source string already in $PROFILE" - fi -fi - -echo "=> Close and reopen your terminal to start using nvm" - +#!/bin/bash + +set -e + +has() { + type "$1" > /dev/null 2>&1 + return $? +} + +if [ -z "$NVM_DIR" ]; then + NVM_DIR="$HOME/.nvm" +fi + +if ! has "curl"; then + if has "wget"; then + # Emulate curl with wget + curl() { + ARGS="$* " + ARGS=${ARGS/-s /-q } + ARGS=${ARGS/-o /-O } + wget $ARGS + } + fi +fi + +install_from_git() { + if [ -z "$NVM_SOURCE" ]; then + NVM_SOURCE="https://github.com/creationix/nvm.git" + fi + + if [ -d "$NVM_DIR/.git" ]; then + echo "=> nvm is already installed in $NVM_DIR, trying to update" + echo -e "\r=> \c" + cd "$NVM_DIR" && git pull 2> /dev/null || { + echo >&2 "Failed to update nvm, run 'git pull' in $NVM_DIR yourself.." + } + else + # Cloning to $NVM_DIR + echo "=> Downloading nvm from git to '$NVM_DIR'" + echo -e "\r=> \c" + mkdir -p "$NVM_DIR" + git clone "$NVM_SOURCE" "$NVM_DIR" + fi +} + +install_as_script() { + if [ -z "$NVM_SOURCE" ]; then + NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh" + fi + + # Downloading to $NVM_DIR + mkdir -p "$NVM_DIR" + if [ -d "$NVM_DIR/nvm.sh" ]; then + echo "=> nvm is already installed in $NVM_DIR, trying to update" + else + echo "=> Downloading nvm as script to '$NVM_DIR'" + fi + curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || { + echo >&2 "Failed to download '$NVM_SOURCE'.." + return 1 + } +} + +if [ -z "$METHOD" ]; then + # Autodetect install method + if has "git"; then + install_from_git + elif has "curl"; then + install_as_script + else + echo >&2 "You need git, curl or wget to install nvm" + exit 1 + fi +else + if [ "$METHOD" = "git" ]; then + if ! has "git"; then + echo >&2 "You need git to install nvm" + exit 1 + fi + install_from_git + fi + if [ "$METHOD" = "script" ]; then + if ! has "curl"; then + echo >&2 "You need curl or wget to install nvm" + exit 1 + fi + install_as_script + fi +fi + +echo + +# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile). +if [ -z "$PROFILE" ]; then + if [ -f "$HOME/.bash_profile" ]; then + PROFILE="$HOME/.bash_profile" + elif [ -f "$HOME/.zshrc" ]; then + PROFILE="$HOME/.zshrc" + elif [ -f "$HOME/.profile" ]; then + PROFILE="$HOME/.profile" + fi +fi + +SOURCE_STR="[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\" # This loads nvm" + +if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then + if [ -z $PROFILE ]; then + echo "=> Profile not found. Tried ~/.bash_profile ~/.zshrc and ~/.profile." + echo "=> Create one of them and run this script again" + else + echo "=> Profile $PROFILE not found" + echo "=> Create it (touch $PROFILE) and run this script again" + fi + echo " OR" + echo "=> Append the following line to the correct file yourself:" + echo + echo " $SOURCE_STR" + echo +else + if ! grep -qc 'nvm.sh' $PROFILE; then + echo "=> Appending source string to $PROFILE" + echo "" >> "$PROFILE" + echo $SOURCE_STR >> "$PROFILE" + else + echo "=> Source string already in $PROFILE" + fi +fi + +echo "=> Close and reopen your terminal to start using nvm" + diff --git a/nvm-exec b/nvm-exec index b78c967..4325c78 100755 --- a/nvm-exec +++ b/nvm-exec @@ -1,14 +1,14 @@ -#!/bin/bash - -DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -source "$DIR/nvm.sh" - -if [ -n "$NODE_VERSION" ]; then - nvm use $NODE_VERSION || (echo "NODE_VERSION not set" && exit 127) -else - nvm use || (echo "No .nvmrc file found" && exit 127) -fi - -exec $@ - +#!/bin/bash + +DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$DIR/nvm.sh" + +if [ -n "$NODE_VERSION" ]; then + nvm use $NODE_VERSION || (echo "NODE_VERSION not set" && exit 127) +else + nvm use || (echo "No .nvmrc file found" && exit 127) +fi + +exec $@ + diff --git a/nvm.sh b/nvm.sh index 22b5ed0..e69de29 100644 --- a/nvm.sh +++ b/nvm.sh @@ -1,637 +0,0 @@ -# Node Version Manager -# Implemented as a bash function -# To use source this file from your bash profile -# -# Implemented by Tim Caswell -# with much bash help from Matthew Ranney - -NVM_SCRIPT_SOURCE="$_" - -nvm_has() { - type "$1" > /dev/null 2>&1 - return $? -} - -# Make zsh glob matching behave same as bash -# This fixes the "zsh: no matches found" errors -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 - export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname "${NVM_SCRIPT_SOURCE:-$0}") > /dev/null && pwd) -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="http://nodejs.org/dist" -fi - -# 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="$(nvm_find_up '.nvmrc')" - if [ -e "$dir/.nvmrc" ]; then - echo "$dir/.nvmrc" - fi -} - -# Obtain nvm version from rc file -nvm_rc_version() { - local NVMRC_PATH="$(nvm_find_nvmrc)" - if [ -e "$NVMRC_PATH" ]; then - NVM_RC_VERSION=`cat "$NVMRC_PATH" | head -n 1` - echo "Found '$NVMRC_PATH' with version <$NVM_RC_VERSION>" - fi -} - -# Expand a version using the version cache -nvm_version() { - local PATTERN=$1 - local VERSION - # The default version is the current one - if [ -z "$PATTERN" ]; then - PATTERN='current' - fi - - VERSION=`nvm_ls $PATTERN | tail -n1` - echo "$VERSION" - - if [ "$VERSION" = 'N/A' ]; then - return - fi -} - -nvm_remote_version() { - local PATTERN=$1 - local VERSION - VERSION=`nvm_ls_remote $PATTERN | tail -n1` - echo "$VERSION" - - if [ "$VERSION" = 'N/A' ]; then - return - fi -} - -nvm_normalize_version() { - echo "$1" | sed -e 's/^v//' | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }' -} - -nvm_format_version() { - echo "$1" | sed -e 's/^\([0-9]\)/v\1/g' -} - -nvm_strip_path() { - echo "$1" | sed -e "s#$NVM_DIR/[^/]*$2[^:]*:##g" -e "s#:$NVM_DIR/[^/]*$2[^:]*##g" -e "s#$NVM_DIR/[^/]*$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 MINIMAL="0.8.6" - local VERSION=$1 - [ $(nvm_normalize_version $VERSION) -ge $(nvm_normalize_version $MINIMAL) ] -} - -nvm_ls() { - local PATTERN=$1 - local VERSIONS='' - if [ "$PATTERN" = 'current' ]; then - echo `node -v 2>/dev/null` - return - fi - - if [ -f "$NVM_DIR/alias/$PATTERN" ]; then - nvm_version `cat $NVM_DIR/alias/$PATTERN` - return - fi - # If it looks like an explicit version, don't do anything funny - if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then - VERSIONS="$PATTERN" - else - VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "$(nvm_format_version $PATTERN)*" -exec basename '{}' ';' \ - | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n` - fi - if [ -z "$VERSIONS" ]; then - echo "N/A" - return - fi - echo "$VERSIONS" - return -} - -nvm_ls_remote() { - local PATTERN=$1 - local VERSIONS - local GREP_OPTIONS='' - if [ -n "$PATTERN" ]; then - PATTERN=`nvm_format_version "$PATTERN"` - else - PATTERN=".*" - fi - VERSIONS=`curl -s $NVM_NODEJS_ORG_MIRROR/ \ - | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \ - | \grep -w "${PATTERN}" \ - | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n` - if [ -z "$VERSIONS" ]; then - echo "N/A" - return - fi - echo "$VERSIONS" - return -} - -nvm_checksum() { - if nvm_has "shasum"; then - checksum=$(shasum $1 | awk '{print $1}') - elif nvm_has "sha1"; then - checksum=$(sha1 -q $1) - else - checksum=$(sha1sum $1 | awk '{print $1}') - fi - - if [ "$checksum" = "$2" ]; then - return - elif [ -z "$2" ]; then - echo 'Checksums empty' #missing in raspberry pi binary - return - else - echo 'Checksums do not match.' - return 1 - fi -} - -nvm_print_versions() { - local VERSION - local FORMAT - local CURRENT=`nvm_version current` - echo "$1" | while read VERSION; do - if [ "$VERSION" = "$CURRENT" ]; then - FORMAT='\033[0;32m-> %9s\033[0m' - elif [ -d "$NVM_DIR/$VERSION" ]; then - FORMAT='\033[0;34m%12s\033[0m' - else - FORMAT='%12s' - fi - printf "$FORMAT\n" $VERSION - done -} - -nvm() { - if [ $# -lt 1 ]; then - nvm help - return - fi - - # Try to figure out the os and arch for binary fetching - local uname="$(uname -a)" - local os= - local arch="$(uname -m)" - local GREP_OPTIONS='' - case "$uname" in - Linux\ *) os=linux ;; - Darwin\ *) os=darwin ;; - SunOS\ *) os=sunos ;; - FreeBSD\ *) os=freebsd ;; - esac - case "$uname" in - *x86_64*) arch=x64 ;; - *i*86*) arch=x86 ;; - *armv6l*) arch=arm-pi ;; - esac - - # initialize local variables - local VERSION - local ADDITIONAL_PARAMETERS - local ALIAS - - case $1 in - "help" ) - echo - echo "Node Version Manager" - 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 " nvm uninstall Uninstall a version" - echo " nvm use Modify PATH to use . Uses .nvmrc if available" - echo " nvm run [] Run with as arguments. Uses .nvmrc if available for " - 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 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 copy-packages Install global NPM packages contained in to current version" - echo - echo "Example:" - echo " nvm install v0.10.24 Install a specific version number" - echo " nvm use 0.10 Use the latest available 0.10.x release" - echo " nvm run 0.10.24 myApp.js Run myApp.js using node v0.10.24" - echo " nvm alias default 0.10.24 Set default node version on a shell" - echo - echo "Note:" - echo " to remove, delete or uninstall nvm - just remove ~/.nvm, ~/.npm and ~/.bower folders" - echo - ;; - - "install" ) - # initialize local variables - local binavail - local t - local url - local sum - local tarball - local nobinary - local version_not_provided=0 - local provided_version - - if ! nvm_has "curl"; then - echo 'NVM Needs curl to proceed.' >&2; - return 1 - fi - - if [ $# -lt 2 ]; then - version_not_provided=1 - nvm_rc_version - if [ -z "$NVM_RC_VERSION" ]; then - nvm help - return - fi - fi - - shift - - nobinary=0 - if [ "$1" = "-s" ]; then - nobinary=1 - shift - fi - - if [ "$os" = "freebsd" ]; then - nobinary=1 - fi - - provided_version=$1 - if [ -z "$provided_version" ]; then - if [ $version_not_provided -ne 1 ]; then - nvm_rc_version - fi - provided_version="$NVM_RC_VERSION" - fi - [ -d "$NVM_DIR/$provided_version" ] && echo "$provided_version is already installed." && return - - VERSION=`nvm_remote_version $provided_version` - ADDITIONAL_PARAMETERS='' - - shift - - while [ $# -ne 0 ] - do - ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1" - shift - done - - if [ -d "$NVM_DIR/$VERSION" ]; then - echo "$VERSION is already installed." - nvm use "$VERSION" - return $? - fi - - if [ "$VERSION" = "N/A" ]; then - echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." - return 3 - fi - - # skip binary install if no binary option specified. - if [ $nobinary -ne 1 ]; then - # shortcut - try the binary if possible. - if [ -n "$os" ]; then - if nvm_binary_available "$VERSION"; then - t="$VERSION-$os-$arch" - url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz" - sum=`curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt | \grep node-${t}.tar.gz | awk '{print $1}'` - local tmpdir="$NVM_DIR/bin/node-${t}" - local tmptarball="$tmpdir/node-${t}.tar.gz" - if ( - mkdir -p "$tmpdir" && \ - curl -L -C - --progress-bar $url -o "$tmptarball" && \ - nvm_checksum "$tmptarball" $sum && \ - tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \ - rm -f "$tmptarball" && \ - mv "$tmpdir" "$NVM_DIR/$VERSION" - ) - then - nvm use $VERSION - return; - else - echo "Binary download failed, trying source." >&2 - rm -rf "$tmptarball" "$tmpdir" - fi - fi - fi - fi - - echo "Additional options while compiling: $ADDITIONAL_PARAMETERS" - - tarball='' - sum='' - make='make' - if [ "$os" = "freebsd" ]; then - make='gmake' - MAKE_CXX="CXX=c++" - fi - local tmpdir="$NVM_DIR/src" - local tmptarball="$tmpdir/node-$VERSION.tar.gz" - if [ "`curl -Is "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then - tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" - sum=`curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt | \grep node-$VERSION.tar.gz | awk '{print $1}'` - elif [ "`curl -Is "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then - tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" - fi - if ( - [ -n "$tarball" ] && \ - mkdir -p "$tmpdir" && \ - curl -L --progress-bar $tarball -o "$tmptarball" && \ - nvm_checksum "$tmptarball" $sum && \ - tar -xzf "$tmptarball" -C "$tmpdir" && \ - cd "$tmpdir/node-$VERSION" && \ - ./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \ - $make $MAKE_CXX && \ - rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \ - $make $MAKE_CXX install - ) - then - nvm use $VERSION - if ! nvm_has "npm" ; then - echo "Installing npm..." - if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then - echo "npm requires node v0.2.3 or higher" - elif [ "`expr "$VERSION" : '\(^v0\.2\.\)'`" != '' ]; then - if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then - echo "npm requires node v0.2.3 or higher" - else - curl https://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh - fi - else - curl https://npmjs.org/install.sh | clean=yes sh - fi - fi - else - echo "nvm: install $VERSION failed!" - return 1 - fi - ;; - "uninstall" ) - [ $# -ne 2 ] && nvm help && return - PATTERN=`nvm_format_version $2` - if [ "$PATTERN" = `nvm_version` ]; then - echo "nvm: Cannot uninstall currently-active node version, $PATTERN." - return 1 - fi - VERSION=`nvm_version $PATTERN` - if [ ! -d $NVM_DIR/$VERSION ]; then - echo "$VERSION version is not installed..." - return; - fi - - t="$VERSION-$os-$arch" - - # Delete all files related to target version. - rm -rf "$NVM_DIR/src/node-$VERSION" \ - "$NVM_DIR/src/node-$VERSION.tar.gz" \ - "$NVM_DIR/bin/node-${t}" \ - "$NVM_DIR/bin/node-${t}.tar.gz" \ - "$NVM_DIR/$VERSION" 2>/dev/null - echo "Uninstalled node $VERSION" - - # Rm any aliases that point to uninstalled version. - for ALIAS in `\grep -l $VERSION $NVM_DIR/alias/* 2>/dev/null` - do - nvm unalias `basename $ALIAS` - done - - ;; - "deactivate" ) - if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin.*"` != 0 ] ; then - export PATH=`nvm_strip_path "$PATH" "/bin"` - hash -r - echo "$NVM_DIR/*/bin removed from \$PATH" - else - echo "Could not find $NVM_DIR/*/bin in \$PATH" - fi - if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then - export MANPATH=`nvm_strip_path "$MANPATH" "/share/man"` - echo "$NVM_DIR/*/share/man removed from \$MANPATH" - else - echo "Could not find $NVM_DIR/*/share/man in \$MANPATH" - fi - if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ] ; then - export NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"` - echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH" - else - echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH" - fi - ;; - "use" ) - if [ $# -eq 0 ]; then - nvm help - return 127 - fi - if [ $# -eq 1 ]; then - nvm_rc_version - if [ -n "$NVM_RC_VERSION" ]; then - VERSION=`nvm_version $NVM_RC_VERSION` - fi - else - VERSION=`nvm_version $2` - fi - if [ -z "$VERSION" ]; then - nvm help - return 127 - fi - if [ -z "$VERSION" ]; then - VERSION=`nvm_version $2` - fi - if [ ! -d "$NVM_DIR/$VERSION" ]; then - echo "$VERSION version is not installed yet" - return 1 - fi - # Strip other version from PATH - PATH=`nvm_strip_path "$PATH" "/bin"` - # Prepend current version - PATH=`nvm_prepend_path "$PATH" "$NVM_DIR/$VERSION/bin"` - 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_DIR/$VERSION/share/man"` - # Strip other version from NODE_PATH - NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"` - # Prepend current version - NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"` - export PATH - hash -r - export MANPATH - export NODE_PATH - export NVM_PATH="$NVM_DIR/$VERSION/lib/node" - export NVM_BIN="$NVM_DIR/$VERSION/bin" - echo "Now using node $VERSION" - ;; - "run" ) - local provided_version - local has_checked_nvmrc=0 - # run given version of node - shift - if [ $# -lt 1 ]; then - nvm_rc_version && has_checked_nvmrc=1 - if [ -n "$NVM_RC_VERSION" ]; then - VERSION=`nvm_version $NVM_RC_VERSION` - else - VERSION='N/A' - fi - if [ $VERSION = "N/A" ]; then - nvm help - return 127 - fi - fi - - provided_version=$1 - if [ -n "$provided_version" ]; then - VERSION=`nvm_version $provided_version` - if [ $VERSION = "N/A" ]; then - provided_version='' - if [ $has_checked_nvmrc -ne 1 ]; then - nvm_rc_version && has_checked_nvmrc=1 - fi - VERSION=`nvm_version $NVM_RC_VERSION` - else - shift - fi - fi - - if [ ! -d "$NVM_DIR/$VERSION" ]; then - echo "$VERSION version is not installed yet" - return; - fi - RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"` - RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"` - echo "Running node $VERSION" - NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@" - ;; - "ls" | "list" ) - nvm_print_versions "`nvm_ls $2`" - if [ $# -eq 1 ]; then - nvm alias - fi - return - ;; - "ls-remote" | "list-remote" ) - nvm_print_versions "`nvm_ls_remote $2`" - return - ;; - "current" ) - nvm_version current - ;; - "alias" ) - mkdir -p $NVM_DIR/alias - if [ $# -le 2 ]; then - local DEST - for ALIAS in $NVM_DIR/alias/$2*; do - if [ -e "$ALIAS" ]; then - DEST=`cat $ALIAS` - VERSION=`nvm_version $DEST` - if [ "$DEST" = "$VERSION" ]; then - echo "$(basename $ALIAS) -> $DEST" - else - echo "$(basename $ALIAS) -> $DEST (-> $VERSION)" - fi - fi - done - return - fi - if [ -z "$3" ]; then - rm -f $NVM_DIR/alias/$2 - echo "$2 -> *poof*" - return - fi - mkdir -p $NVM_DIR/alias - VERSION=`nvm_version $3` - if [ $? -ne 0 ]; then - echo "! WARNING: Version '$3' does not exist." >&2 - fi - echo $3 > "$NVM_DIR/alias/$2" - if [ ! "$3" = "$VERSION" ]; then - echo "$2 -> $3 (-> $VERSION)" - else - echo "$2 -> $3" - fi - ;; - "unalias" ) - mkdir -p $NVM_DIR/alias - [ $# -ne 2 ] && nvm help && return 127 - [ ! -f "$NVM_DIR/alias/$2" ] && echo "Alias $2 doesn't exist!" && return - rm -f $NVM_DIR/alias/$2 - echo "Deleted alias $2" - ;; - "copy-packages" ) - if [ $# -ne 2 ]; then - nvm help - return 127 - fi - VERSION=`nvm_version $2` - local ROOT=`(nvm use $VERSION && npm -g root)` - local ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1)) - - # declare local INSTALLS first, otherwise it doesn't work in zsh - local INSTALLS - INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f $(($ROOTDEPTH + 2)) | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "` - - npm install -g ${INSTALLS[@]} - ;; - "clear-cache" ) - rm -f $NVM_DIR/v* 2>/dev/null - echo "Cache cleared." - ;; - "version" ) - nvm_version $2 - ;; - "--version" ) - echo "0.7.0" - ;; - * ) - nvm help - ;; - esac -} - -nvm ls default >/dev/null && nvm use default >/dev/null || true - diff --git a/package.json b/package.json index b1750d4..8ac2be4 100644 --- a/package.json +++ b/package.json @@ -1,33 +1,33 @@ -{ - "name": "nvm", - "version": "0.7.0", - "description": "Node Version Manager - Simple bash script to manage multiple active node.js versions", - "directories": { - "test": "test" - }, - "scripts": { - "test": "urchin test", - "test/fast": "urchin -f test/fast", - "test/slow": "urchin -f test/slow" - }, - "repository": { - "type": "git", - "url": "git://github.com/creationix/nvm.git" - }, - "keywords": [ - "nvm", - "node", - "version", - "manager" - ], - "author": "Tim Caswell ", - "license": "MIT", - "bugs": { - "url": "https://github.com/creationix/nvm/issues" - }, - "homepage": "https://github.com/creationix/nvm", - "devDependencies": { - "urchin": "~0.0.2" - } -} - +{ + "name": "nvm", + "version": "0.7.0", + "description": "Node Version Manager - Simple bash script to manage multiple active node.js versions", + "directories": { + "test": "test" + }, + "scripts": { + "test": "urchin test", + "test/fast": "urchin -f test/fast", + "test/slow": "urchin -f test/slow" + }, + "repository": { + "type": "git", + "url": "git://github.com/creationix/nvm.git" + }, + "keywords": [ + "nvm", + "node", + "version", + "manager" + ], + "author": "Tim Caswell ", + "license": "MIT", + "bugs": { + "url": "https://github.com/creationix/nvm/issues" + }, + "homepage": "https://github.com/creationix/nvm", + "devDependencies": { + "urchin": "~0.0.2" + } +} + 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." index 78d0022..69adf6f 100755 --- "a/test/fast/Aliases/Running \"nvm alias \" should list but one alias." +++ "b/test/fast/Aliases/Running \"nvm alias \" should list but one alias." @@ -1,4 +1,4 @@ -#!/bin/sh - -. ../../../nvm.sh -[ $(nvm alias test1 | wc -l) = '2' ] +#!/bin/sh + +. ../../../nvm.sh +[ $(nvm alias test1 | wc -l) = '2' ] diff --git "a/test/fast/Aliases/Running \"nvm alias\" should list all aliases." "b/test/fast/Aliases/Running \"nvm alias\" should list all aliases." index 42b1945..7bcbeb9 100755 --- "a/test/fast/Aliases/Running \"nvm alias\" should list all aliases." +++ "b/test/fast/Aliases/Running \"nvm alias\" should list all aliases." @@ -1,4 +1,4 @@ -#!/bin/sh - -. ../../../nvm.sh -[ $(nvm alias | wc -l) = '10' ] +#!/bin/sh + +. ../../../nvm.sh +[ $(nvm alias | wc -l) = '10' ] diff --git a/test/fast/Aliases/setup_dir b/test/fast/Aliases/setup_dir index 3649602..e3894b0 100755 --- a/test/fast/Aliases/setup_dir +++ b/test/fast/Aliases/setup_dir @@ -1,6 +1,6 @@ -#!/bin/sh - -for i in $(seq 1 10) - do - echo v0.0.$i > ../../../alias/test$i -done +#!/bin/sh + +for i in $(seq 1 10) + do + echo v0.0.$i > ../../../alias/test$i +done 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." index dda41ba..fc45b4a 100755 --- "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." @@ -1,12 +1,12 @@ -#!/bin/sh - -mkdir ../../../v0.1.3 -mkdir ../../../v0.2.3 - -. ../../../nvm.sh - -# The result should contain only the appropriate version numbers. -nvm ls 0.2 | grep v0.2.3 && -nvm ls 0.1 | grep -v v0.2.3 && -nvm ls 0.1 | grep v0.1.3 && -nvm ls v0.2 | grep v0.2.3 +#!/bin/sh + +mkdir ../../../v0.1.3 +mkdir ../../../v0.2.3 + +. ../../../nvm.sh + +# The result should contain only the appropriate version numbers. +nvm ls 0.2 | grep v0.2.3 && +nvm ls 0.1 | grep -v v0.2.3 && +nvm ls 0.1 | grep v0.1.3 && +nvm ls v0.2 | grep v0.2.3 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." index be0dddb..76da233 100755 --- "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." @@ -1,18 +1,18 @@ -#!/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 - -# The result should contain the version numbers. -nvm ls | grep v0.0.1 && -nvm ls | grep v0.0.3 && -nvm ls | grep v0.0.9 && -nvm ls | grep v0.3.1 && -nvm ls | grep v0.3.3 && -nvm ls | grep v0.3.9 +#!/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 + +# The result should contain the version numbers. +nvm ls | grep v0.0.1 && +nvm ls | grep v0.0.3 && +nvm ls | grep v0.0.9 && +nvm ls | grep v0.3.1 && +nvm ls | grep v0.3.3 && +nvm ls | grep v0.3.9 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." index 38ba260..13db72f 100755 --- "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." @@ -1,5 +1,5 @@ -#!/bin/sh - -. ../../nvm.sh -nvm alias test v0.1.2 -[ "$(cat ../../alias/test)" = "v0.1.2" ] +#!/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." index d9293ed..27416f4 100755 --- "a/test/fast/Running \"nvm current\" should display current nvm environment." +++ "b/test/fast/Running \"nvm current\" should display current nvm environment." @@ -1,6 +1,6 @@ -#!/bin/sh - -die () { echo $@ ; exit 1; } - -. ../../nvm.sh -[ "$(nvm current)" = "$(node -v)" ] || die "Failed to find current version" +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../nvm.sh +[ "$(nvm current)" = "$(node -v)" ] || die "Failed to find current version" 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." index 2149273..d26a4a8 100755 --- "a/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." +++ "b/test/fast/Running \"nvm deactivate\" should unset the nvm environment variables." @@ -1,14 +1,14 @@ -#!/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 v0.2.3 && -[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3" - -nvm deactivate && -[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3" +#!/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 v0.2.3 && +[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3" + +nvm deactivate && +[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3" 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" index 2f556e9..db46727 100755 --- "a/test/fast/Running \"nvm install\" with an invalid version fails nicely" +++ "b/test/fast/Running \"nvm install\" with an invalid version fails nicely" @@ -1,7 +1,7 @@ -#!/bin/sh - -die () { echo $@ ; exit 1; } - -. ../../nvm.sh -[ "$(nvm install invalid.invalid)" = "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" - +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../nvm.sh +[ "$(nvm install invalid.invalid)" = "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." index f8ed49d..f021f9e 100755 --- "a/test/fast/Running \"nvm unalias\" should remove the alias file." +++ "b/test/fast/Running \"nvm unalias\" should remove the alias file." @@ -1,6 +1,6 @@ -#!/bin/sh - -echo v0.1.2 > ../../alias/test -. ../../nvm.sh -nvm unalias test -! [ -e ../../alias/test ] +#!/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." index ba1ddbb..b1d1eee 100755 --- "a/test/fast/Running \"nvm uninstall\" should remove the appropriate directory." +++ "b/test/fast/Running \"nvm uninstall\" should remove the appropriate directory." @@ -1,10 +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' ] +#!/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/Sourcing nvm.sh should make the nvm command available. b/test/fast/Sourcing nvm.sh should make the nvm command available. index 24f8efa..5e268b1 100755 --- a/test/fast/Sourcing nvm.sh should make the nvm command available. +++ b/test/fast/Sourcing nvm.sh should make the nvm command available. @@ -1,4 +1,4 @@ -#!/bin/sh - -. ../../nvm.sh -nvm +#!/bin/sh + +. ../../nvm.sh +nvm diff --git a/test/fast/Unit tests/nvm_prepend_path b/test/fast/Unit tests/nvm_prepend_path index ef0af81..26d54f5 100755 --- a/test/fast/Unit tests/nvm_prepend_path +++ b/test/fast/Unit tests/nvm_prepend_path @@ -1,18 +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 " +#!/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_strip_path b/test/fast/Unit tests/nvm_strip_path index 0d119aa..aefa3fe 100755 --- a/test/fast/Unit tests/nvm_strip_path +++ b/test/fast/Unit tests/nvm_strip_path @@ -1,11 +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 - -STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"` - -[ "$STRIPPED_PATH" = "/usr/bin:/usr/local/bin" ] || die "Not correctly stripped: $STRIPPED_PATH " +#!/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 + +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/setup b/test/fast/setup index f98394b..659dac3 100755 --- a/test/fast/setup +++ b/test/fast/setup @@ -1,12 +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 -) +#!/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 index 64e097c..d1f9da8 100755 --- a/test/fast/setup_dir +++ b/test/fast/setup_dir @@ -1,13 +1,13 @@ -#!/bin/sh - -( - cd ../.. - - # Back up - - mkdir -p bak - for SRC in v* src alias; do - [ -e "$SRC" ] && mv "$SRC" bak - done - true -) +#!/bin/sh + +( + cd ../.. + + # Back up + + mkdir -p bak + for SRC in v* src alias; do + [ -e "$SRC" ] && mv "$SRC" bak + done + true +) diff --git a/test/fast/teardown b/test/fast/teardown index bd269eb..6b48167 100755 --- a/test/fast/teardown +++ b/test/fast/teardown @@ -1,10 +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 -) +#!/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 +) diff --git a/test/fast/teardown_dir b/test/fast/teardown_dir index 065269a..5200a17 100755 --- a/test/fast/teardown_dir +++ b/test/fast/teardown_dir @@ -1,13 +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 -) +#!/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/slow/nvm install/install already installed uses it b/test/slow/nvm install/install already installed uses it index 7e42c07..527c71d 100755 --- a/test/slow/nvm install/install already installed uses it +++ b/test/slow/nvm install/install already installed uses it @@ -1,24 +1,24 @@ -#!/bin/sh - -die () { echo $@ ; exit 1; } - -. ../../../nvm.sh - -[ "$(nvm install invalid.invalid)" = "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" - +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "$(nvm install invalid.invalid)" = "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/slow/nvm install/install from binary b/test/slow/nvm install/install from binary index 82124e0..4b761ec 100755 --- a/test/slow/nvm install/install from binary +++ b/test/slow/nvm install/install from binary @@ -1,17 +1,17 @@ -#!/bin/sh - -set -e -. ../../../nvm.sh - -NVM_TEST_VERSION=v0.10.7 - -# Remove the stuff we're clobbering. -[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION - -# Install from binary -nvm install $NVM_TEST_VERSION - -# Check -[ -d ../../../$NVM_TEST_VERSION ] -nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION - +#!/bin/sh + +set -e +. ../../../nvm.sh + +NVM_TEST_VERSION=v0.10.7 + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from binary +nvm install $NVM_TEST_VERSION + +# Check +[ -d ../../../$NVM_TEST_VERSION ] +nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION + diff --git a/test/slow/nvm install/install from source b/test/slow/nvm install/install from source index fdb5c0e..f804a5d 100755 --- a/test/slow/nvm install/install from source +++ b/test/slow/nvm install/install from source @@ -1,17 +1,17 @@ -#!/bin/sh - -set -e -. ../../../nvm.sh - -NVM_TEST_VERSION=v0.10.7 - -# Remove the stuff we're clobbering. -[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION - -# Install from source -nvm install -s $NVM_TEST_VERSION - -# Check -[ -d ../../../$NVM_TEST_VERSION ] -nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION - +#!/bin/sh + +set -e +. ../../../nvm.sh + +NVM_TEST_VERSION=v0.10.7 + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from source +nvm install -s $NVM_TEST_VERSION + +# Check +[ -d ../../../$NVM_TEST_VERSION ] +nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION + diff --git a/test/slow/nvm install/install two versions and use the latest one b/test/slow/nvm install/install two versions and use the latest one index 951eabb..0cddcf5 100755 --- a/test/slow/nvm install/install two versions and use the latest one +++ b/test/slow/nvm install/install two versions and use the latest one @@ -1,24 +1,24 @@ -#!/bin/sh - -set -e -. ../../../nvm.sh - -# Remove the stuff we're clobbering. -[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7 -[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12 - -# Install from binary -nvm install 0.9.7 -nvm install 0.9.12 - -# Check -[ -d ../../../v0.9.7 ] -[ -d ../../../v0.9.12 ] - -# Use the first one -nvm use 0.9.7 - -# Use the latest one -nvm use 0.9 -node --version | grep v0.9.12 - +#!/bin/sh + +set -e +. ../../../nvm.sh + +# Remove the stuff we're clobbering. +[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7 +[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12 + +# Install from binary +nvm install 0.9.7 +nvm install 0.9.12 + +# Check +[ -d ../../../v0.9.7 ] +[ -d ../../../v0.9.12 ] + +# Use the first one +nvm use 0.9.7 + +# Use the latest one +nvm use 0.9 +node --version | grep v0.9.12 + diff --git a/test/slow/nvm install/install version specified in .nvmrc from binary b/test/slow/nvm install/install version specified in .nvmrc from binary index dec2fe1..9bff4f6 100644 --- a/test/slow/nvm install/install version specified in .nvmrc from binary +++ b/test/slow/nvm install/install version specified in .nvmrc from binary @@ -1,20 +1,20 @@ -#!/bin/sh - -set -e -. ../../../nvm.sh - -NVM_TEST_VERSION=v0.10.7 - -# Remove the stuff we're clobbering. -[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION - -# Install from binary -cat "$NVM_TEST_VERSION" > .nvmrc - -nvm install - -# Check -[ -d ../../../$NVM_TEST_VERSION ] -nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION - - +#!/bin/sh + +set -e +. ../../../nvm.sh + +NVM_TEST_VERSION=v0.10.7 + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from binary +cat "$NVM_TEST_VERSION" > .nvmrc + +nvm install + +# Check +[ -d ../../../$NVM_TEST_VERSION ] +nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION + + diff --git a/test/slow/nvm install/install version specified in .nvmrc from source b/test/slow/nvm install/install version specified in .nvmrc from source index 6910228..1d6e875 100644 --- a/test/slow/nvm install/install version specified in .nvmrc from source +++ b/test/slow/nvm install/install version specified in .nvmrc from source @@ -1,20 +1,20 @@ -#!/bin/sh - -set -e -. ../../../nvm.sh - -NVM_TEST_VERSION=v0.10.7 - -# Remove the stuff we're clobbering. -[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION - -# Install from binary -cat "$NVM_TEST_VERSION" > .nvmrc - -nvm install -s - -# Check -[ -d ../../../$NVM_TEST_VERSION ] -nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION - - +#!/bin/sh + +set -e +. ../../../nvm.sh + +NVM_TEST_VERSION=v0.10.7 + +# Remove the stuff we're clobbering. +[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION + +# Install from binary +cat "$NVM_TEST_VERSION" > .nvmrc + +nvm install -s + +# Check +[ -d ../../../$NVM_TEST_VERSION ] +nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION + + diff --git a/test/slow/nvm install/setup_dir b/test/slow/nvm install/setup_dir index 50dc4e4..322593a 100755 --- a/test/slow/nvm install/setup_dir +++ b/test/slow/nvm install/setup_dir @@ -1,6 +1,6 @@ -#!/bin/sh - -if [ -f ".nvmrc" ]; then - mv .nvmrc .nvmrc.bak -fi - +#!/bin/sh + +if [ -f ".nvmrc" ]; then + mv .nvmrc .nvmrc.bak +fi + diff --git a/test/slow/nvm install/teardown_dir b/test/slow/nvm install/teardown_dir index 3f107c9..1ab6f20 100755 --- a/test/slow/nvm install/teardown_dir +++ b/test/slow/nvm install/teardown_dir @@ -1,13 +1,13 @@ -#!/bin/sh - -. ../../../nvm.sh -nvm uninstall v0.10.7 - -if [ -f ".nvmrc" ]; then - rm .nvmrc -fi - -if [ -f ".nvmrc.bak" ]; then - mv .nvmrc.bak .nvmrc -fi - +#!/bin/sh + +. ../../../nvm.sh +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/slow/nvm run/Running \"nvm run 0.x\" should work" "b/test/slow/nvm run/Running \"nvm run 0.x\" should work" index cc56601..16e18fa 100755 --- "a/test/slow/nvm run/Running \"nvm run 0.x\" should work" +++ "b/test/slow/nvm run/Running \"nvm run 0.x\" should work" @@ -1,9 +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" - +#!/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" index d462488..5ebb84e 100755 --- "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" @@ -1,13 +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" - +#!/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 index 870a22c..a57e7d0 100755 --- a/test/slow/nvm run/setup_dir +++ b/test/slow/nvm run/setup_dir @@ -1,9 +1,9 @@ -#!/bin/sh - -. ../../../nvm.sh -nvm install 0.10.7 - -if [ -f ".nvmrc" ]; then - mv .nvmrc .nvmrc.bak -fi - +#!/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 index 120ea83..3bbed47 100755 --- a/test/slow/nvm run/teardown_dir +++ b/test/slow/nvm run/teardown_dir @@ -1,11 +1,11 @@ -#!/bin/sh - -. ../../../nvm.sh -nvm uninstall v0.10.7 - -rm .nvmrc - -if [ -f ".nvmrc.bak" ]; then - mv .nvmrc.bak .nvmrc -fi - +#!/bin/sh + +. ../../../nvm.sh +nvm uninstall v0.10.7 + +rm .nvmrc + +if [ -f ".nvmrc.bak" ]; then + mv .nvmrc.bak .nvmrc +fi +