mirror of
https://github.com/tj/n.git
synced 2024-11-24 19:46:56 +01:00
Using PREFIX
This commit is contained in:
parent
38187f856c
commit
c41e3b1300
@ -32,7 +32,7 @@ or
|
|||||||
`n` by default installs node to _/usr/local/n/versions_, from
|
`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.
|
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.
|
To alter where `n` operates simply export __N_PREFIX__ to whatever you prefer.
|
||||||
|
|
||||||
|
10
bin/n
10
bin/n
@ -3,6 +3,7 @@
|
|||||||
# Library version
|
# Library version
|
||||||
|
|
||||||
VERSION="0.0.1"
|
VERSION="0.0.1"
|
||||||
|
PREFIX=${PREFIX-/usr/local}
|
||||||
N_PREFIX=${N_PREFIX-/usr/local}
|
N_PREFIX=${N_PREFIX-/usr/local}
|
||||||
VERSIONS_DIR=$N_PREFIX/n/versions
|
VERSIONS_DIR=$N_PREFIX/n/versions
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ display_n_version() {
|
|||||||
check_current_version() {
|
check_current_version() {
|
||||||
if test `which node`; then
|
if test `which node`; then
|
||||||
installed=`node --version`
|
installed=`node --version`
|
||||||
installed=${installed:1:${#installed}}
|
installed=${installed##*v}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ install_node() {
|
|||||||
|
|
||||||
# remove "v"
|
# remove "v"
|
||||||
if test "${version:0:1}" = "v"; then
|
if test "${version:0:1}" = "v"; then
|
||||||
version=${version:1:${#version}}
|
version=${installed##*v}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# already active
|
# already active
|
||||||
@ -117,11 +118,10 @@ install_node() {
|
|||||||
|
|
||||||
# installed
|
# installed
|
||||||
local dir=$VERSIONS_DIR/$version
|
local dir=$VERSIONS_DIR/$version
|
||||||
local prefix=/usr/local
|
|
||||||
if test -d $dir; then
|
if test -d $dir; then
|
||||||
cd $dir \
|
cd $dir \
|
||||||
&& cp -fr $dir/include/node $prefix/include \
|
&& cp -fr $dir/include/node $PREFIX/include \
|
||||||
&& cp -f $dir/bin/node $prefix/bin/node
|
&& cp -f $dir/bin/node $PREFIX/bin/node
|
||||||
# install
|
# install
|
||||||
else
|
else
|
||||||
local dir="node-v$version"
|
local dir="node-v$version"
|
||||||
|
Loading…
Reference in New Issue
Block a user