Permalink
Browse files

Add NAVE_DEBUG, and use ~/.nave instead of the nave dir

  • Loading branch information...
1 parent f7458d5 commit bce616abae5569ca7a7c102913b2a7835e943fc2 @isaacs committed Feb 2, 2011
Showing with 19 additions and 3 deletions.
  1. +19 −3 nave.sh
View
22 nave.sh
@@ -11,14 +11,18 @@
# a subshell with that version's folder at the start of the
# $PATH
-# nave --version <version> program.js
+# nave use <version> program.js
# Like "nave use", but have the subshell start the program.js
# immediately.
# When told to use a version:
# Ensure that the version exists, install it, and
# then add its prefix to the PATH, and start a subshell.
+if [ "$NAVE_DEBUG" != "" ]; then
+ set -x
+fi
+
tar=${TAR-tar}
main () {
@@ -42,8 +46,20 @@ main () {
)/$(basename -- "$SYM")
done
- export NAVE_SRC="$(dirname -- "$SELF_PATH")/src"
- export NAVE_ROOT="$(dirname -- "$SELF_PATH")/installed"
+ if ! [ -d "$NAVE_DIR" ]; then
+ if [ -d "$HOME" ]; then
+ NAVE_DIR="$HOME"/.nave
+ else
+ NAVE_DIR=/usr/local/nave
+ fi
+ fi
+ if ! [ -d "$NAVE_DIR" ] && ! mkdir -p -- "$NAVE_DIR"; then
+ NAVE_DIR="$(dirname -- "$SELF_PATH")"
+ fi
+
+ export NAVE_DIR
+ export NAVE_SRC="$NAVE_DIR/src"
+ export NAVE_ROOT="$NAVE_DIR/installed"
ensure_dir "$NAVE_SRC"
ensure_dir "$NAVE_ROOT"

0 comments on commit bce616a

Please sign in to comment.