UNPKG

@fontoxml/fontoxml-development-tools

Version:

Development tools for Fonto.

47 lines (41 loc) 1.28 kB
import Version from './Version.js'; const PREVIOUS_MINOR_VERSIONS_BY_MAJOR = { 8: ['7.17'], 7: ['6.11', '6.12'], }; /** * Returns the supported minor versions for upgrading to the specified version. * * NOTE: Even though full versions are returned, the main use is to use it for compatibility * checking for upgrading; And thus the whole minor range is supported, not just that specific * patch/full version. * * @param {Version} version * * @return {Version[] | null} */ export function getUpgradeSupportedVersions(version) { if (version.isUnversioned) { return null; } let minorVersions; if (version.minor === 0) { const previousMinorVersions = PREVIOUS_MINOR_VERSIONS_BY_MAJOR[version.major]; if (!previousMinorVersions) { return null; } minorVersions = previousMinorVersions.slice(); } else { const previousMinorVersion = new Version(version.format('core')); previousMinorVersion.minor -= 1; previousMinorVersion.patch = 0; minorVersions = [previousMinorVersion.format('minor')]; } // Include the minor of the specified version. minorVersions.push(version.format('minor')); // Map to Version appending `.0` to the minor version. return minorVersions.map( (minorVersion) => new Version(`${minorVersion}.0`) ); }