Skip to content

Commit 1ae8d5a

Browse files
committed
improve auto switching between nave/naveless envs
I'd run into a weird state jumping between different projects, and this makes the 'if nave_should_auto; then exec nave auto; fi' trick work properly. Without having it only unset, it would end up exiting, and never coming back, so I had to keep manually running 'exec nave auto', which reduces the utility of it's 'auto'-ness.
1 parent 040b150 commit 1ae8d5a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

nave.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ nave_auto () {
443443
nave_use "${args[@]}" "$SHELL" -c "$(enquote_all "$@")"
444444
fi
445445
elif [ "$#" -eq 0 ]; then
446-
nave_exit
446+
nave_unset
447+
exec "$SHELL"
447448
else
448449
nave_exit "$@"
449450
fi
@@ -531,11 +532,10 @@ nave_install () {
531532
fi
532533
}
533534

534-
nave_exit () {
535+
nave_unset () {
535536
if [ -n "$NAVEPATH" ]; then
536537
export PATH=${PATH//$NAVEPATH:/}
537538
fi
538-
export NAVE_EXIT='1'
539539
unset NAVE_NPX
540540
unset NAVE_AUTO_RC
541541
unset NAVE_AUTO_CFG
@@ -553,10 +553,13 @@ nave_exit () {
553553
unset NODE_PATH
554554
unset NAVE_LOGIN
555555
unset NAVE_DIR
556-
unset npm_config_binroot
557-
unset npm_config_root
558-
unset npm_config_manroot
559556
unset npm_config_prefix
557+
}
558+
559+
nave_exit () {
560+
export NAVE_EXIT='1'
561+
562+
nave_unset
560563

561564
if [ "$#" -gt 0 ]; then
562565
"$SHELL" -c "$(enquote_all "$@")"
@@ -973,9 +976,6 @@ nave_run () {
973976
NAVEVERSIONARG="$versionarg" \
974977
NAVENAME="$name" \
975978
NAVE="$nave" \
976-
npm_config_binroot="$bin"\
977-
npm_config_root="$lib" \
978-
npm_config_manroot="$man" \
979979
npm_config_prefix="$prefix" \
980980
NODE_PATH="$lib" \
981981
NAVE_LOGIN="$isLogin" \

snapshots/nave-auto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mock nave use bar 6.9.0 exec echo (pwd=$PWD/test/cases/nave-auto/a)
4242
a/b
4343
mock nave use foo 1.2.3 exec echo (pwd=$PWD/test/cases/nave-auto/a/b)
4444
a/b/c
45-
mock nave exit
45+
4646
a/b/c/d/e/f
4747
mock nave use 4.2.0 exec echo (pwd=$PWD/test/cases/nave-auto/a/b/c/d/e/f)
4848
cmd-a

0 commit comments

Comments
 (0)