mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 06:12:03 +03:00
85da9bdeb2
- currently if Ghost has a version of something like `3.37.0-pre.abc.def`, Ghost will return `3.37.0-pre.abc` as the full version - this hides parts of the version which are useful for debugging - this commit updates the logic to join together all prerelease elements so we keep the full string
26 lines
726 B
JavaScript
26 lines
726 B
JavaScript
const semver = require('semver');
|
|
const packageInfo = require('../../../package.json');
|
|
const version = packageInfo.version;
|
|
const plainVersion = version.match(/^(\d+\.)?(\d+\.)?(\d+)/)[0];
|
|
|
|
let _private = {};
|
|
|
|
_private.compose = function compose(type) {
|
|
switch (type) {
|
|
case 'pre':
|
|
return plainVersion + '-' + semver.prerelease(version).join('.');
|
|
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;
|
|
|