@@ -30,14 +30,28 @@ function applyNvmRcUse
30
30
# No nvmrc file found.
31
31
if test $nvmrc_applied != " N/A"
32
32
# nvmrc was applied, but no nvmrc file found.
33
+
34
+ # We know that we will uset the variable.
35
+ set -g nvmrc_applied " N/A"
36
+
37
+ useDefaultNVMVersion
38
+ if test " $nvm_use_default_status " = " 0"
39
+ return
40
+ end
41
+
33
42
# Unload nvm.
34
43
__nvm unload
35
- set -g nvmrc_applied " N/A"
36
44
set -g nvmrc_node_version " N/A"
37
45
38
46
if test $nvmrc_announce = " yes"
39
47
echo " nvmrc: Unloaded nvm."
40
48
end
49
+
50
+ return
51
+ end
52
+
53
+ if test $nvmrc_node_version = " N/A"
54
+ useDefaultNVMVersion
41
55
end
42
56
43
57
return
@@ -49,7 +63,7 @@ function applyNvmRcUse
49
63
return
50
64
end
51
65
52
- set -l __nvmrc_node_version (nvm version (cat $_ _nvmrc_file))
66
+ set -l __nvmrc_node_version (__nvm version (cat $_ _nvmrc_file))
53
67
# nvmrc file found.
54
68
if test $_ _nvmrc_node_version = " N/A"
55
69
# nvmrc file specifies a version that nvm does not have installed.
@@ -79,6 +93,21 @@ function applyNvmRcUse
79
93
end
80
94
end
81
95
96
+ # Apply default node version, we do not want to install default version.
97
+ function useDefaultNVMVersion
98
+ # Try to use default version.
99
+ __nvm use default --silent
100
+
101
+ set -g nvm_use_default_status $status
102
+ if test " $nvm_use_default_status " = " 0"
103
+ # Default version is set.
104
+ set -g nvmrc_node_version (__nvm version)
105
+ if test $nvmrc_announce = " yes"
106
+ echo " nvmrc: Loaded default node version $nvmrc_node_version "
107
+ end
108
+ end
109
+ end
110
+
82
111
# We need to run applyNvmRcUse on the initialization of each session.
83
112
if status is-interactive
84
113
# Set nvmrc_applied to default "N/A" value if not set.
0 commit comments