index.js 497 B

1234567891011121314151617181920
  1. 'use strict';
  2. function parseNodeVersion(version) {
  3. 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
  4. if (!match) {
  5. throw new Error('Unable to parse: ' + version);
  6. }
  7. var res = {
  8. major: parseInt(match[1], 10),
  9. minor: parseInt(match[2], 10),
  10. patch: parseInt(match[3], 10),
  11. pre: match[4] || '',
  12. build: match[5] || '',
  13. };
  14. return res;
  15. }
  16. module.exports = parseNodeVersion;