Last active
September 21, 2017 14:35
-
-
Save nicholascloud/e94b81da151487a2aee48beef0cbd9d9 to your computer and use it in GitHub Desktop.
bash - override cd to test for .nvmrc and instruct nvm to change node versions if present
This file contains 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
# hook into the cd command to test for the presence | |
# of .npmrc and then switch node versions based on that | |
cd() { | |
builtin cd "$@" | |
if [ -d $NVM_DIR ] | |
then | |
if [ -f ./.nvmrc ] | |
then | |
# cat ./.nvmrc | |
LOCAL_NODE_VERSION=`cat .nvmrc` | |
nvm use $LOCAL_NODE_VERSION | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment