-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnvm.fish
32 lines (26 loc) · 823 Bytes
/
nvm.fish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env fish
#####################
### NVM functions ###
#####################
function nvm
bass source ~/.config/nvm/nvm.sh --no-use ';' nvm $argv
end
function nvm_find_nvmrc
bass source ~/.config/nvm/nvm.sh --no-use ';' nvm_find_nvmrc
end
function load_nvm # --on-variable="PWD"
set -l default_node_version (nvm version default)
set -l node_version (nvm version)
set -l nvmrc_path (nvm_find_nvmrc)
if test -n "$nvmrc_path"
set -l nvmrc_node_version (nvm version (cat $nvmrc_path))
if test "$nvmrc_node_version" = "N/A"
nvm install (cat $nvmrc_path)
else if test "$nvmrc_node_version" != "$node_version"
nvm use $nvmrc_node_version
end
else if test "$node_version" != "$default_node_version"
echo "Reverting to default Node version"
nvm use default
end
end