Compare commits

...

13 Commits

Author SHA1 Message Date
Jordan Harband
4a7275a0c6 Ensuring paths are in quotes, to preserve spaces. 2014-05-04 00:39:46 -07:00
Jordan Harband
c77be55cdc Updating "nvm run" tests. 2014-05-04 00:39:32 -07:00
Jordan Harband
e195fccdb7 Escaping backticks 2014-05-03 23:29:21 -07:00
Jordan Harband
87516039a8 Using portable conditional syntax. 2014-05-02 23:28:42 -07:00
Koen Punt
80e349edb1 locate .nvmrc without find
instead of using find and actually cd'ing into directories
we're now using simple string replacement on the `pwd`
2014-05-02 23:02:34 -07:00
Jordan Harband
038c1f3d0f Find .nvmrc files upwards. 2014-05-02 23:02:34 -07:00
Jordan Harband
66455f7c77 Refactor so "finding .nvmrc" can be done in a bash function. 2014-05-02 23:02:34 -07:00
Jordan Harband
a69eae10e3 Merge pull request #405 from reqshark/master
github raw served from new subdomain
2014-04-26 10:03:41 -07:00
Bent Cardan
13b87449e8 github raw served from new subdomain 2014-04-26 03:48:06 -04:00
Jordan Harband
222250f2d1 v0.5.1 2014-04-25 10:47:59 -07:00
Jordan Harband
77f4490391 Using markdown footnotes. 2014-04-25 10:47:07 -07:00
Jordan Harband
0871131dfd Make sure nvm-exec can use .nvmrc logic. Fixes #402, obviates #403. 2014-04-25 10:38:21 -07:00
Jordan Harband
e6bd207624 When auto-printing "help" on a command other than "help", return a nonzero exit code. 2014-04-25 10:35:52 -07:00
7 changed files with 48 additions and 24 deletions

View File

@@ -2,7 +2,7 @@ language: c # defaults to ruby
install:
- sudo apt-get install ksh zsh -y
before_script:
- curl -o /tmp/urchin https://raw.github.com/scraperwiki/urchin/master/urchin && chmod +x /tmp/urchin
- curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin && chmod +x /tmp/urchin
script:
- NVM_DIR=$TRAVIS_BUILD_DIR make URCHIN=/tmp/urchin test

View File

@@ -1,4 +1,4 @@
# Node Version Manager [![Build Status](https://travis-ci.org/creationix/nvm.svg?branch=master)](https://travis-ci.org/creationix/nvm)
# Node Version Manager [![Build Status](https://travis-ci.org/creationix/nvm.svg?branch=master)][3]
## Installation
@@ -6,13 +6,13 @@ First you'll need to make sure your system has a c++ compiler. For OSX, XCode w
### Install script
To install you could use the [install script](https://github.com/creationix/nvm/blob/v0.5.0/install.sh) using cURL:
To install you could use the [install script][2] using cURL:
curl https://raw.github.com/creationix/nvm/v0.5.0/install.sh | sh
curl https://raw.githubusercontent.com/creationix/nvm/v0.5.1/install.sh | sh
or Wget:
wget -qO- https://raw.github.com/creationix/nvm/v0.5.0/install.sh | sh
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.5.1/install.sh | sh
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
@@ -90,7 +90,7 @@ The above copyright notice and this permission notice shall be included in all c
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](https://github.com/scraperwiki/urchin). Install Urchin (and other dependencies) like so:
Tests are written in [Urchin]. Install Urchin (and other dependencies) like so:
npm install
@@ -163,3 +163,8 @@ After the v0.8.6 release of node, nvm tries to install from binary packages. But
nvm install -s 0.8.6
[1]: https://github.com/creationix/nvm.git
[2]: https://github.com/creationix/nvm/blob/v0.5.1/install.sh
[3]: https://travis-ci.org/creationix/nvm
[Urchin]: https://github.com/scraperwiki/urchin

View File

@@ -45,7 +45,7 @@ install_from_git() {
install_as_script() {
if [ -z "$NVM_SOURCE" ]; then
NVM_SOURCE="https://raw.github.com/creationix/nvm/master/nvm.sh"
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh"
fi
# Downloading to $NVM_DIR

View File

@@ -4,12 +4,11 @@ DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$DIR/nvm.sh"
if [ ! "$NODE_VERSION" ]; then
echo 'NODE_VERSION not set'
exit 1
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
nvm use $NODE_VERSION
exec $@

37
nvm.sh
View File

@@ -34,11 +34,30 @@ 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() {
if [ -e .nvmrc ]; then
NVM_RC_VERSION=`cat .nvmrc | head -n 1`
echo "Found .nvmrc files with version <$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
}
@@ -422,7 +441,7 @@ nvm() {
"use" )
if [ $# -eq 0 ]; then
nvm help
return
return 127
fi
if [ $# -eq 1 ]; then
nvm_rc_version
@@ -434,7 +453,7 @@ nvm() {
fi
if [ -z "$VERSION" ]; then
nvm help
return
return 127
fi
if [ -z "$VERSION" ]; then
VERSION=`nvm_version $2`
@@ -484,7 +503,7 @@ nvm() {
fi
if [ $VERSION = "N/A" ]; then
nvm help
return
return 127
fi
fi
@@ -564,7 +583,7 @@ nvm() {
;;
"unalias" )
mkdir -p $NVM_DIR/alias
[ $# -ne 2 ] && nvm help && return
[ $# -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"
@@ -572,7 +591,7 @@ nvm() {
"copy-packages" )
if [ $# -ne 2 ]; then
nvm help
return
return 127
fi
VERSION=`nvm_version $2`
local ROOT=`(nvm use $VERSION && npm -g root)`
@@ -592,7 +611,7 @@ nvm() {
nvm_version $2
;;
"--version" )
echo "nvm v0.5.0"
echo "nvm v0.5.1"
;;
* )
nvm help

View File

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

View File

@@ -6,7 +6,8 @@ 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 .nvmrc files with version <0.10.7>" ] || die "`nvm run` failed to print out the \"found in .nvmrc\" message"
[ "$(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"