Skip to content

Commit

Permalink
Adding Symlink to currently used version of node so that globally ins…
Browse files Browse the repository at this point in the history
…talled modules are accessible from the PATH if the path is extended.
  • Loading branch information
johnhamelink committed Jan 20, 2012
1 parent 148939d commit 051e7d6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bin/n
Expand Up @@ -51,7 +51,7 @@ test -z "$GET" && abort "curl or wget required"
display_help() {
cat <<-help
Usage: n [options] [COMMAND] [config]
Usage: n [options] [COMMAND] [config]
Commands:
Expand Down Expand Up @@ -98,7 +98,7 @@ check_current_version() {
if test $? -eq 0; then
active=`node --version`
active=${active#v}
fi
fi
}

#
Expand Down Expand Up @@ -140,7 +140,7 @@ install_node() {
&& cp -fr $dir/include/node $N_PREFIX/include \
&& cp -f $dir/bin/node $N_PREFIX/bin/node \
&& cp -f $dir/bin/node-waf $N_PREFIX/bin/node-waf \
&& cp -fr $dir/lib/node/* $N_PREFIX/lib/node/.
&& cp -fr $dir/lib/node/* $N_PREFIX/lib/node/ \
# install
else
local tarball="node-v$version.tar.gz"
Expand Down Expand Up @@ -176,7 +176,8 @@ install_node() {
&& cleanup $version \
&& mkdir -p $dir \
&& echo $config > "$dir/.config" \
&& n $version
&& n $version \
&& ln -s "$N_PREFIX/n/versions/$version" "$N_PREFIX/n/current"
fi
}

Expand All @@ -192,7 +193,7 @@ cleanup() {
log "removing source"
rm -fr $dir
fi

if test -f "$dir.tar.gz"; then
log "removing tarball"
rm -fr "$dir.tar.gz"
Expand Down Expand Up @@ -222,7 +223,7 @@ display_bin_path_for_version() {
local bin=$VERSIONS_DIR/$version/bin/node
if test -f $bin; then
printf $bin
else
else
abort "$1 is not installed"
fi
}
Expand All @@ -241,7 +242,7 @@ execute_with_version() {

if test -f $bin; then
$bin $@
else
else
abort "$1 is not installed"
fi
}
Expand Down

0 comments on commit 051e7d6

Please sign in to comment.