1
0
Fork 0

add first pass at adding NVM to modules

pull/1217/head
Jim Ray 8 years ago
parent 4f19700919
commit c4dbc3c199

@ -0,0 +1,29 @@
NVM
====
Configures [Node][1] local gem installation, loads version managers, and defines
aliases.
NVM
---
[The Node Version Manager (NVM)][2], allows for managing multiple, isolated
Node installations and node_modules sets in the home directory.
#### Auto-Switch
To enable auto switching the Node version on directory change based on the
.nvmrc file, add the following line to *zpreztorc*:
zstyle ':prezto:module:node:nvm' auto-switch 'yes'
Authors
-------
*The authors of this module should be contacted via the [issue tracker][5].*
- [Jim Ray](https://github.com/jimiray)
[1]: https://nodejs.org/en/
[2]: https://github.com/creationix/nvm

@ -0,0 +1,22 @@
### NVM
export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"
autoload -U add-zsh-hook
add-zsh-hook chpwd load-nvmrc
load-nvmrc
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" != "N/A" ] && [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
Loading…
Cancel
Save