JSPM

is-node-modern

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9497
  • Score
    100M100P100Q122521F
  • License MIT

Detects if node is modern, with helpful command line tools

Package Exports

  • is-node-modern

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-node-modern) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.