1.0.2 • Published 7 years ago

nvmrc-check v1.0.2

Weekly downloads
356
License
MIT
Repository
github
Last release
7 years ago

nvmrc-check

1) Add .nvmrc file to project root with version number:

8.0

2) Add to package.json as script

scripts {
  "postinstall": "nvmrc-check --node $(cat .nvmrc)"
}

3) If current node version doesn't match, script fails.

Note: Use nvm trick with zsh to call nvm use automatically whenever you enter a directory that contains an .nvmrc file. Or add to your .bash_profile (adapted from unix stackexchange thread):

cd () { builtin cd "$@" && chpwd; }
pushd () { builtin pushd "$@" && chpwd; }
popd () { builtin popd "$@" && chpwd; }
chpwd () {

FILE=$PWD/.nvmrc

if [ -f $FILE ];
then
   nvm install $(cat .nvmrc)
fi
}