This commit is contained in:
AJ ONeal 2018-03-28 00:08:49 -06:00
parent 361e1dd788
commit 540c7430df
2 changed files with 28 additions and 32 deletions

View File

@ -1,4 +1,6 @@
## semver-utils ## semver-utils.js
| Sponsored by [ppl](https://ppl.family)
Some utils that aren't provided by the mainstream `semver` module. Some utils that aren't provided by the mainstream `semver` module.
@ -11,10 +13,9 @@ npm install --save semver-utils
```javascript ```javascript
'use strict'; 'use strict';
var semverUtils = require('semver-utils') var semverUtils = require('semver-utils');
, version = require('./package.json').version var version = require('./package.json').version;
, semver = semverUtils.parse(version) var semver = semverUtils.parse(version);
;
console.log(semver); console.log(semver);
``` ```
@ -30,8 +31,7 @@ console.log(semver);
Turns a string such as `1.0.6-1+build-623` into the object Turns a string such as `1.0.6-1+build-623` into the object
{ { semver: '1.0.6-1+build-623'
semver: '1.0.6-1+build-623'
, version: '1.0.6' , version: '1.0.6'
, major: '1' , major: '1'
, minor: '0' , minor: '0'
@ -46,8 +46,7 @@ returns `null` on **error**
Creates a string such as `1.0.6-1+build-623` from the object Creates a string such as `1.0.6-1+build-623` from the object
{ { major: '1'
major: '1'
, minor: '0' , minor: '0'
, patch: '6' , patch: '6'
, release: '1' , release: '1'
@ -96,29 +95,25 @@ Creates a range string such as `>= 1.1.7 < 2.0.0 || 1.1.3`
from an array of semver objects (and operators) such as from an array of semver objects (and operators) such as
[ [
{ { "semver": ">= v1.1.7"
"semver": ">= v1.1.7" , "operator": ">="
, "operator": ">=" , "major": 1
, "major": 1 , "minor": 1
, "minor": 1 , "patch": 7
, "patch": 7
} }
, { , { "semver": "< v2.0.0"
"semver": "< v2.0.0" , "operator": "<"
, "operator": "<" , "major": 2
, "major": 2 , "minor": 0
, "minor": 0 , "patch": 0
, "patch": 0
} }
, { , { "operator": "||"
"operator": "||"
} }
, { , { "semver": "v1.1.3"
"semver": "v1.1.3" , "operator": "="
, "operator": "=" , "major": 1
, "major": 1 , "minor": 1
, "minor": 1 , "patch": 3
, "patch": 3
} }
] ]

View File

@ -1,14 +1,15 @@
{ {
"name": "semver-utils", "name": "semver-utils",
"version": "1.1.0", "version": "1.1.1",
"description": "Tools for manipulating semver strings and objects", "description": "Tools for manipulating semver strings and objects",
"homepage": "https://git.coolaj86.com/coolaj86/semver-utils.js",
"main": "semver-utils.js", "main": "semver-utils.js",
"scripts": { "scripts": {
"test": "mocha" "test": "mocha"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/coolaj86/semver-utils.git" "url": "git://git.coolaj86.com/coolaj86/semver-utils.js.git"
}, },
"keywords": [ "keywords": [
"semver", "semver",