is-node-modern

1.0.0 • Public • Published

is-node-modern NPM Module

Detects if node is modern, with helpful command line tools

Linux Build MacOS Build Windows Build

Coverage Status Dependency Status bitHound Overall Score

Install

npm install --save-dev is-node-modern

then add to your package.json following script:

  "scripts"{
    "my-action": "is-node-modern && thing-I-want-to-do-in-modern-node-versions || is-node-not-modern"
  }

By default it will consider modern node versions that equal or above LTS version.

Also you can specify custom threshold, like:

  "scripts"{
    "my-action": "is-node-modern 6 && thing-I-want-to-do-in-node-v6-or-above || is-node-not-modern 6"
  }

to execute provided commands within custom threshold.

Example

CLI

Running eslint in node version equal or above 4 (current LTS version):

  "scripts"{
    "lint": "eslint *.js",
    "ci-lint": "is-node-modern && npm run lint || is-node-not-modern"
  }

Now you can have CI for node versions below 4, while running latest eslint only within node@4+.

Node

Also, it could be used as regular node module:

var isNodeModern = require('is-node-modern');
 
if (isNodeModern())
{
  // only run in node@4+
}
 
if (isNodeModern(6))
{
  // only run in node@6+
}

License

Is-Node-Modern is released under the MIT license.

Package Sidebar

Install

npm i is-node-modern

Weekly Downloads

224

Version

1.0.0

License

MIT

Last publish

Collaborators

  • alexindigo