pax_global_header00006660000000000000000000000064134242063250014513gustar00rootroot0000000000000052 comment=69cad9e2396a98e9ce3390ba451508852be7065e parse-node-version-1.0.1/000077500000000000000000000000001342420632500152325ustar00rootroot00000000000000parse-node-version-1.0.1/.editorconfig000066400000000000000000000003261342420632500177100ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf [*.md] trim_trailing_whitespace = false parse-node-version-1.0.1/.eslintrc000066400000000000000000000000301342420632500170470ustar00rootroot00000000000000{ "extends": "gulp" } parse-node-version-1.0.1/.gitattributes000066400000000000000000000000161342420632500201220ustar00rootroot00000000000000* text eol=lf parse-node-version-1.0.1/.gitignore000066400000000000000000000011461342420632500172240ustar00rootroot00000000000000# Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules # Users Environment Variables .lock-wscript # Garbage files .DS_Store parse-node-version-1.0.1/.npmrc000066400000000000000000000000231342420632500163450ustar00rootroot00000000000000package-lock=false parse-node-version-1.0.1/.travis.yml000066400000000000000000000002021342420632500173350ustar00rootroot00000000000000sudo: false language: node_js node_js: - '10' - '8' - '6' - '4' - '0.12' - '0.10' after_script: - npm run coveralls parse-node-version-1.0.1/LICENSE000066400000000000000000000021711342420632500162400ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2018 Blaine Bublitz and Eric Schoffstall Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. parse-node-version-1.0.1/README.md000066400000000000000000000035431342420632500165160ustar00rootroot00000000000000

# parse-node-version [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] Turn node's process.version into something useful. ## Usage ```js var nodeVersion = require('parse-node-version')(process.version); console.log( nodeVersion.major, nodeVersion.minor, nodeVersion.patch, nodeVersion.pre, nodeVersion.build ); ``` ## API ### parseVersion(nodeVersionString) Takes a node version string (usually `process.version`) and returns an object with the `major`/`minor`/`patch` (which will all be numbers) and `pre`/`build` keys (which will always be a string). If the version doesn't contain any pre-release or build information, the properties will be returned as empty string. ## License MIT [downloads-image]: http://img.shields.io/npm/dm/parse-node-version.svg [npm-url]: https://www.npmjs.com/package/parse-node-version [npm-image]: http://img.shields.io/npm/v/parse-node-version.svg [travis-url]: https://travis-ci.org/gulpjs/parse-node-version [travis-image]: http://img.shields.io/travis/gulpjs/parse-node-version.svg?label=travis-ci [appveyor-url]: https://ci.appveyor.com/project/gulpjs/parse-node-version [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/parse-node-version.svg?label=appveyor [coveralls-url]: https://coveralls.io/r/gulpjs/parse-node-version [coveralls-image]: http://img.shields.io/coveralls/gulpjs/parse-node-version/master.svg [gitter-url]: https://gitter.im/gulpjs/gulp [gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg parse-node-version-1.0.1/appveyor.yml000066400000000000000000000007541342420632500176300ustar00rootroot00000000000000# http://www.appveyor.com/docs/appveyor-yml # http://www.appveyor.com/docs/lang/nodejs-iojs environment: matrix: # node.js - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "6" - nodejs_version: "8" - nodejs_version: "10" install: - ps: Install-Product node $env:nodejs_version - npm install test_script: - node --version - npm --version - cmd: npm test build: off # build version format version: "{build}" parse-node-version-1.0.1/index.js000066400000000000000000000007611342420632500167030ustar00rootroot00000000000000'use strict'; function parseNodeVersion(version) { var match = version.match(/^v(\d{1,2})\.(\d{1,2})\.(\d{1,2})(?:-([0-9A-Za-z-.]+))?(?:\+([0-9A-Za-z-.]+))?$/); // eslint-disable-line max-len if (!match) { throw new Error('Unable to parse: ' + version); } var res = { major: parseInt(match[1], 10), minor: parseInt(match[2], 10), patch: parseInt(match[3], 10), pre: match[4] || '', build: match[5] || '', }; return res; } module.exports = parseNodeVersion; parse-node-version-1.0.1/package.json000066400000000000000000000017061342420632500175240ustar00rootroot00000000000000{ "name": "parse-node-version", "version": "1.0.1", "description": "Turn node's process.version into something useful.", "author": "Gulp Team (http://gulpjs.com/)", "contributors": [ "Blaine Bublitz " ], "repository": "gulpjs/parse-node-version", "license": "MIT", "engines": { "node": ">= 0.10" }, "main": "index.js", "files": [ "LICENSE", "index.js" ], "scripts": { "lint": "eslint .", "pretest": "npm run lint", "test": "mocha --async-only", "cover": "istanbul cover _mocha --report lcovonly", "coveralls": "npm run cover && istanbul-coveralls" }, "dependencies": {}, "devDependencies": { "eslint": "^2.13.0", "eslint-config-gulp": "^3.0.1", "expect": "^1.20.2", "istanbul": "^0.4.3", "istanbul-coveralls": "^1.0.3", "mocha": "^3.5.3" }, "keywords": [ "process.version", "node version", "version parse" ] } parse-node-version-1.0.1/test/000077500000000000000000000000001342420632500162115ustar00rootroot00000000000000parse-node-version-1.0.1/test/.eslintrc000066400000000000000000000001031342420632500200270ustar00rootroot00000000000000{ "extends": "gulp/test", "rules": { "no-console": 0 } } parse-node-version-1.0.1/test/index.js000066400000000000000000000052461342420632500176650ustar00rootroot00000000000000'use strict'; var expect = require('expect'); var parseNodeVersion = require('../'); describe('parseNodeVersion', function() { it('takes process.version and returns all numbers', function(done) { var nodeVersion = parseNodeVersion(process.version); expect(nodeVersion.major).toBeA('number'); expect(nodeVersion.minor).toBeA('number'); expect(nodeVersion.patch).toBeA('number'); done(); }); it('takes any string formatted like a v8.8.8 and returns all numbers', function(done) { var nodeVersion = parseNodeVersion('v8.8.8'); expect(nodeVersion.major).toEqual(8); expect(nodeVersion.minor).toEqual(8); expect(nodeVersion.patch).toEqual(8); done(); }); it('throws if given an invalid version', function(done) { function invalid() { parseNodeVersion('8.8.8'); } expect(invalid).toThrow('Unable to parse: 8.8.8'); done(); }); it('matches on exactly the version - it cannot be padded', function(done) { function invalid() { parseNodeVersion('vv8.8.8'); } expect(invalid).toThrow('Unable to parse: vv8.8.8'); done(); }); it('only matches 2 digits in any position', function(done) { function invalid() { parseNodeVersion('v8.111.8'); } expect(invalid).toThrow('Unable to parse: v8.111.8'); done(); }); it('always returns strings if no pre-release or build metadata', function(done) { var nodeVersion = parseNodeVersion(process.version); expect(nodeVersion.pre).toBeA('string'); expect(nodeVersion.pre).toEqual(''); expect(nodeVersion.build).toBeA('string'); expect(nodeVersion.build).toEqual(''); done(); }); it('matches pre-release label with single identifier', function(done) { var nodeVersion = parseNodeVersion('v1.2.3-alpha'); expect(nodeVersion.pre).toEqual('alpha'); done(); }); it('matches pre-release label with multiple identifiers', function(done) { var nodeVersion = parseNodeVersion('v1.2.3-x.7.z.92'); expect(nodeVersion.pre).toEqual('x.7.z.92'); done(); }); it('matches pre-release label with dashes', function(done) { var nodeVersion = parseNodeVersion('v1.2.3-x-7-z.92'); expect(nodeVersion.pre).toEqual('x-7-z.92'); done(); }); it('matches build metadata', function(done) { var nodeVersion = parseNodeVersion('v10.15.0+0-b20181231T20014594'); expect(nodeVersion.build).toEqual('0-b20181231T20014594'); done(); }); it('matches pre-release label and build metadata', function(done) { var nodeVersion = parseNodeVersion('v1.0.0-beta+exp.sha.5114f85'); expect(nodeVersion.pre).toEqual('beta'); expect(nodeVersion.build).toEqual('exp.sha.5114f85'); done(); }); });