2018-01-03 22:20:18 +03:00
|
|
|
const semver = require('semver'),
|
|
|
|
packageInfo = require('../../../package.json'),
|
|
|
|
version = packageInfo.version,
|
|
|
|
plainVersion = version.match(/^(\d+\.)?(\d+\.)?(\d+)/)[0];
|
|
|
|
|
|
|
|
let _private = {};
|
|
|
|
|
|
|
|
_private.compose = function compose(type) {
|
|
|
|
switch (type) {
|
|
|
|
case 'pre':
|
|
|
|
return plainVersion + '-' + semver.prerelease(version)[0] + (semver.prerelease(version)[1] ? '.' + semver.prerelease(version)[1] : '');
|
|
|
|
default:
|
|
|
|
return version;
|
|
|
|
}
|
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;
|
|
|
|
|