2020-04-29 18:44:27 +03:00
|
|
|
const semver = require('semver');
|
|
|
|
const packageInfo = require('../../../package.json');
|
|
|
|
const version = packageInfo.version;
|
|
|
|
const plainVersion = version.match(/^(\d+\.)?(\d+\.)?(\d+)/)[0];
|
2018-01-03 22:20:18 +03:00
|
|
|
|
|
|
|
let _private = {};
|
|
|
|
|
|
|
|
_private.compose = function compose(type) {
|
|
|
|
switch (type) {
|
2018-09-17 21:49:30 +03:00
|
|
|
case 'pre':
|
2020-10-29 15:41:15 +03:00
|
|
|
return plainVersion + '-' + semver.prerelease(version).join('.');
|
2018-09-17 21:49:30 +03:00
|
|
|
default:
|
|
|
|
return version;
|
2018-01-03 22:20:18 +03:00
|
|
|
}
|
2016-10-10 22:14:32 +03:00
|
|
|
};
|
|
|
|
|
2018-01-03 22:20:18 +03:00
|
|
|
// major.minor
|
|
|
|
module.exports.safe = version.match(/^(\d+\.)?(\d+)/)[0];
|
|
|
|
|
|
|
|
// major.minor.patch-{prerelease}
|
|
|
|
module.exports.full = semver.prerelease(version) ? _private.compose('pre') : plainVersion;
|
|
|
|
|
|
|
|
// original string in package.json (can contain pre-release and build suffix)
|
|
|
|
module.exports.original = version;
|
|
|
|
|