is-node-modern

2018-10-16 admin

is-node-modern是什么

什么是is-node-modern,Detects if node is modern, with helpful command line tools

is-node-modern使用教程帮助文档

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.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-42809.html

文章标题:is-node-modern

回到顶部