From 1bf60a04f54ad7fdf6237e575d492e61991882a6 Mon Sep 17 00:00:00 2001 From: Darren DeRidder Date: Tue, 21 Jun 2011 16:33:20 -0400 Subject: [PATCH] Let n play nice on Ubuntu with local node install. * Fix stdin / stderr redirect to work with sh * Fix cd relative path issue * Try to find node and n before defaulting to /usr/local/ * (can still set PREFIX, N_PREFIX env vars to override) * Canadian content eh --- bin/n | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/n b/bin/n index 556bbdb..ebff560 100755 --- a/bin/n +++ b/bin/n @@ -3,8 +3,12 @@ # Library version VERSION="0.4.1" -PREFIX=${PREFIX-/usr/local} -N_PREFIX=${N_PREFIX-/usr/local} +#PREFIX=${PREFIX-/usr/local} +PREFIX=${PREFIX-`which node|sed 's/\/bin\/node$//'`} +#N_PREFIX=${N_PREFIX-/usr/local} +ABSPATH=$(readlink -f $0) +ABSDIR=$(dirname $ABSPATH) +N_PREFIX=${N_PREFIX-`echo $ABSDIR | sed 's/\/n\/bin$//'`} VERSIONS_DIR=$N_PREFIX/n/versions # @@ -149,7 +153,7 @@ install_node() { cd $N_PREFIX/n \ && $GET "http://nodejs.org/dist/$tarball" \ > $tarball \ - && tar -zxf $tarball &> $logpath + && tar -zxf $tarball > $logpath 2>&1 # see if things are alright if test $? -gt 0; then @@ -163,7 +167,7 @@ install_node() { exit 1 fi - cd "node-v$version" \ + cd "$N_PREFIX/n/node-v$version" \ && ./configure --prefix $VERSIONS_DIR/$version $config\ && make install \ && cd .. \