/test-version

检查一个版本号是否满足给定的版本范围

Primary LanguageJavaScriptMIT LicenseMIT

test-version

NPM version build status

Test if a given version matches a version pattern

Install

$ npm install test-version

Usage

const test = require('test-version');

if (test('v1.0.0', '>=1.0.0')) {
    console.log('matched!');
}
else {
    console.log('not matched');
}

Patterns

version can be like:

1.0.0 => 1.0.0
1-0-0 => 1.0.0
v1.0  => 1.0

version pattern can be like:

1.0.0
1.0.x
1.0.*
!1.0.0
~1.0.0
^1.0.0
>1.0.0
<1.0.0
1.0.0...1.9.9
1.0.0~1.9.9