npm-version-compare

1.0.1 • Public • Published

npm-version-compare

npm version Build Status Coverage Status

Compare npm CLI version string with another version string

const npmVersionCompare = require('npm-version-compare');
 
// When npm CLI v6.7.0 is installed
 
(async () => {
  await npmVersionCompare('6.6.0'); // 1
  await npmVersionCompare('6.7.0'); // 0
  await npmVersionCompare('6.8.0'); // -1
})();

Installation

Use npm.

npm install npm-version-compare

API

const npmVersionCompare = require('npm-version-compare');

npmVersionCompare(version)

version: string (SemVer version expression)
Return: Promise<integer> (-1, 0 or 1)

The resultant promise will be fulfilled with:

  • -1 if a given version is greater than the version of currently installed npm
  • 0 if a given version is the same value as the npm version
  • 1 if the npm version is greater than a given version

Related project

License

ISC License © 2018 - 2019 Shinnosuke Watanabe

/npm-version-compare/

    Package Sidebar

    Install

    npm i npm-version-compare

    Weekly Downloads

    492

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    4.37 kB

    Total Files

    4

    Last publish

    Collaborators

    • shinnn