mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
efd1587ee9
refs #9834 - @TODO: the test env eslint needs to use the plugin, not part of this PR
26 lines
790 B
JavaScript
26 lines
790 B
JavaScript
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;
|
|
}
|
|
};
|
|
|
|
// 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;
|
|
|