Skip to content

Commit

Permalink
Using PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jan 5, 2011
1 parent 38187f8 commit c41e3b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Expand Up @@ -32,7 +32,7 @@ or
`n` by default installs node to _/usr/local/n/versions_, from
which it can see what you have currently installed, and activate previously installed versions of node when `n <version>` is invoked again.

Activated nodes are then installed to the prefix _/usr/local_.
Activated nodes are then installed to the prefix _/usr/local_, which of course may be altered via the __PREFIX__ environment variable.

To alter where `n` operates simply export __N_PREFIX__ to whatever you prefer.

Expand Down
10 changes: 5 additions & 5 deletions bin/n
Expand Up @@ -3,6 +3,7 @@
# Library version

VERSION="0.0.1"
PREFIX=${PREFIX-/usr/local}
N_PREFIX=${N_PREFIX-/usr/local}
VERSIONS_DIR=$N_PREFIX/n/versions

Expand Down Expand Up @@ -78,7 +79,7 @@ display_n_version() {
check_current_version() {
if test `which node`; then
installed=`node --version`
installed=${installed:1:${#installed}}
installed=${installed##*v}
fi
}

Expand Down Expand Up @@ -109,19 +110,18 @@ install_node() {

# remove "v"
if test "${version:0:1}" = "v"; then
version=${version:1:${#version}}
version=${installed##*v}
fi

# already active
test "$version" = "$installed" && return

# installed
local dir=$VERSIONS_DIR/$version
local prefix=/usr/local
if test -d $dir; then
cd $dir \
&& cp -fr $dir/include/node $prefix/include \
&& cp -f $dir/bin/node $prefix/bin/node
&& cp -fr $dir/include/node $PREFIX/include \
&& cp -f $dir/bin/node $PREFIX/bin/node
# install
else
local dir="node-v$version"
Expand Down

0 comments on commit c41e3b1

Please sign in to comment.