NodeJS switcher based on package.json.
JavaScript
Latest commit 8f9819d Oct 28, 2016 @Kikobeats Release 3.0.1
Permalink
Failed to load latest commit information.
bin Normalize env vars Oct 28, 2016
test first commit Mar 14, 2016
.bumpedrc first commit Mar 14, 2016
.editorconfig first commit Mar 14, 2016
.gitattributes first commit Mar 14, 2016
.gitignore first commit Mar 14, 2016
.npmignore first commit Mar 14, 2016
.npmrc first commit Mar 14, 2016
.travis.yml first commit Mar 14, 2016
CHANGELOG.md Release 3.0.1 Oct 28, 2016
LICENSE.md first commit Mar 14, 2016
README.md Add NODENGINE_INTERVAL doc Oct 28, 2016
package.json Release 3.0.1 Oct 28, 2016

README.md

nodengine


demo

Last version Build Status Dependency status Dev Dependencies Status NPM Status Donate

NodeJS switcher based on node version declared in package.json.

It needs a global version manager as n or nvm.

Install

$ npm install nodengine --global --production

Usage

Set the desired version range in the package.json

"engines": {
  "node": ">= 0.10"
}

Then just run nodengine to change the current node version to version declared into package.json.

It will use the highest version that satisfies the range.

Automatic switching

Enabling automatic switching consist in a little shell script for check if package.json exists and then runs nodengine.

Add the follow snippet in a file loaded by your shell agent, for example, .extra.

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

chpwd () {
  local PKG

  PKG=$PWD/package.json
  if [ -f "$PKG" ] && [ "$NODENGINE_LAST_DIR" != "$PWD" ]; then
    nodengine
    printf "\033[36m%s\033[0m \033[90m%s\033[0m\n" "nodengine" "$(node --version)"
    NODENGINE_LAST_DIR=$PWD
  fi
}

Fetching new versions

The program use a local cache for avoid fetching versions of node all the time.

By default, new versions of node will be fetch each 5 days.

You can setup the interval using NODENGINE_INTERVAL

For example, if you want to fetch all versions every time that you run the program:

NODENGINE_INTERVAL=0 nodengine

License

MIT © Kiko Beats