[readme] `cdnvm` function: fix shellcheck errors
Resolves #3081
parent
0d9b5c2a00
commit
d1a22a63bd
11
README.md
11
README.md
|
@ -599,8 +599,9 @@ cdnvm() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
alias cd='cdnvm'
|
alias cd='cdnvm'
|
||||||
cd "$PWD"
|
cdnvm "$PWD" || exit
|
||||||
```
|
```
|
||||||
|
|
||||||
This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version.
|
This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version.
|
||||||
|
@ -615,11 +616,14 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e
|
||||||
```zsh
|
```zsh
|
||||||
# place this after nvm initialization!
|
# place this after nvm initialization!
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
|
|
||||||
load-nvmrc() {
|
load-nvmrc() {
|
||||||
local nvmrc_path="$(nvm_find_nvmrc)"
|
local nvmrc_path
|
||||||
|
nvmrc_path="$(nvm_find_nvmrc)"
|
||||||
|
|
||||||
if [ -n "$nvmrc_path" ]; then
|
if [ -n "$nvmrc_path" ]; then
|
||||||
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
|
local nvmrc_node_version
|
||||||
|
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
|
||||||
|
|
||||||
if [ "$nvmrc_node_version" = "N/A" ]; then
|
if [ "$nvmrc_node_version" = "N/A" ]; then
|
||||||
nvm install
|
nvm install
|
||||||
|
@ -631,6 +635,7 @@ load-nvmrc() {
|
||||||
nvm use default
|
nvm use default
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
add-zsh-hook chpwd load-nvmrc
|
add-zsh-hook chpwd load-nvmrc
|
||||||
load-nvmrc
|
load-nvmrc
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue