Awesome
<h2 align="center"> <br> <img src="http://g.recordit.co/pMGKmq4ycR.gif" alt="nodengine"> <br> <br> <p>Automagically switch your Node.js version</p> <p>based on `package.json`</p> <img src="https://img.shields.io/github/tag/Kikobeats/nodengine.svg?style=flat-square" alt="Last version"> <a href="https://www.npmjs.org/package/nodengine"><img src="http://img.shields.io/npm/dm/nodengine.svg?style=flat-square" alt="NPM Status"></a> <br> <br> </h2>nodengine is an automatic way to switch your Node.js version per project reading engines
fields at package.json
.
It needs a global version manager as n or nvm.
If you want know when a new version of node is released, follow our @nodengine bot.
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
.
function 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
}
function cd() { builtin cd "$@" && chpwd; }
function pushd() { builtin pushd "$@" && chpwd; }
function popd() { builtin popd "$@" && chpwd; }
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 fetched after 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