0
0
mirror of https://github.com/tj/n.git synced 2024-11-24 19:46:56 +01:00

Using PREFIX

This commit is contained in:
Tj Holowaychuk 2011-01-05 07:44:55 -08:00
parent 38187f856c
commit c41e3b1300
2 changed files with 6 additions and 6 deletions

View File

@ -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.

10
bin/n
View File

@ -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
@ -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
}
@ -109,7 +110,7 @@ install_node() {
# remove "v"
if test "${version:0:1}" = "v"; then
version=${version:1:${#version}}
version=${installed##*v}
fi
# already active
@ -117,11 +118,10 @@ install_node() {
# 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"