Created
August 18, 2017 09:35
-
-
Save tobiashm/64092ca417361bfefa84046392803719 to your computer and use it in GitHub Desktop.
Change nvm version using RVM hooks (place in ~/.rvm/hooks/after_cd_nvm)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Requirements: | |
# brew install jq node | |
# nvm use system; npm -g install semver | |
if [ -f package.json ]; then | |
requested_node_version=$(jq -r '.engines.node' package.json) | |
if [ "$requested_node_version" != "" ]; then | |
node_version=$(nvm_ls | xargs env NODE_VERSION=system ~/.nvm/nvm-exec semver -r "$requested_node_version") | |
[ "$node_version" != "" ] && [ $(nvm current) != "v$node_version" ] && nvm use "$node_version" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment