You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 534B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. var semver = require('semver');
  3. module.exports = function (version, type) {
  4. if (['major', 'minor', 'patch'].indexOf(type) === -1) {
  5. throw new TypeError('Invalid version type');
  6. }
  7. version = semver.parse(version, {loose: true});
  8. if (!version) {
  9. throw new Error('Version ' + version + ' is not valid semver');
  10. }
  11. version.build = '';
  12. version.prerelease = '';
  13. if (type === 'minor') {
  14. version.patch = 0;
  15. }
  16. if (type === 'major') {
  17. version.patch = 0;
  18. version.minor = 0;
  19. }
  20. return version.format();
  21. };