diff --git a/Readme.md b/Readme.md index d4c63f0..c6b54c7 100644 --- a/Readme.md +++ b/Readme.md @@ -32,6 +32,8 @@ 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 ` is invoked again. + Activated nodes are then installed to the prefix _/usr/local_. + To alter where `n` operates simply export __N_PREFIX__ to whatever you prefer. ## License diff --git a/bin/n b/bin/n index 298687a..2abd72c 100755 --- a/bin/n +++ b/bin/n @@ -115,17 +115,27 @@ install_node() { # 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 # install - local dir="node-v$version" - cd $PREFIX/n \ - && $GET "http://nodejs.org/dist/node-v$version.tar.gz" \ - > "$dir.tar.gz" \ - && tar -zxf "$dir.tar.gz" \ - && cd $dir \ - && ./configure --prefix $VERSIONS_DIR/$version\ - && make install \ - && cd .. \ - && cleanup $version + else + local dir="node-v$version" + cd $PREFIX/n \ + && $GET "http://nodejs.org/dist/node-v$version.tar.gz" \ + > "$dir.tar.gz" \ + && tar -zxf "$dir.tar.gz" \ + && cd $dir \ + && ./configure --prefix $VERSIONS_DIR/$version\ + && make install \ + && cd .. \ + && cleanup $version \ + && n $version + fi } #