Parse package.json, inspect
engines property and ensure command runs with right node.js version - avoiding as much compilation as possible.
Engineer makes it trivial to run a command in an environment where
npm match those specified by a particular package.json's
engines field. It
attempts to do this using already-present node binaries to save time if at all
possible. Otherwise, it will reach out to the Internet, download, compile and
install a satisfying version of Node.Js.
Engineer will try in this order, using the first satisfying version it finds:
- Inspect the version of node.js in the
$PATHto see if it satifies
- Inspect the version of node.js versions already installed locally via
naveto see if any of those satifies
- Pick the maximum remote version of node.js which satisfies via
This makes it a no-brainer to run an arbitrary package under whatever version
of node it needs. Engineer uses
semver to do the heavy lifting of
installing and checking for valid node.js versions.
npm install -g node-engineer
execute command with node version acceptable to engines package.json property usage: engineer Options: -c Shell command [required] -f Path to package.json [required] Missing required arguments: c, f
# "node":">=0.6.19 <0.7.0" # $PATH contains node 0.6.17 # No existing locally-installed nave versions $ engineer -f package.json -c 'npm ls' System non-Nave Node.JS version 0.6.17 does not satisfy range >=0.6.19 <0.7.0 local versions:  Remote version 0.6.19 satisfies range >=0.6.19 <0.7.0 running cmd: ["./node_modules/nave/nave.sh","use","0.6.19","npm","ls"]
# "node":">=0.6.0 <0.7.0" # $PATH contains node 0.6.17 $ engineer -f package.json -c 'npm ls' System non-Nave Node.JS version 0.6.17 satisfies range >=0.6.0 <0.7.0 running cmd: ["npm","ls"] firstname.lastname@example.org /Users/nialljohiggins/projects/node-engineer ├── email@example.com extraneous ├─┬ firstname.lastname@example.org extraneous │ ├── email@example.com │ ├── firstname.lastname@example.org │ ├── email@example.com │ ├── firstname.lastname@example.org │ └─┬ email@example.com │ └── firstname.lastname@example.org ├── email@example.com ├─┬ firstname.lastname@example.org │ └── email@example.com └── firstname.lastname@example.org
This is a glue package which relies on: