const semver = require('semver'); const { BuildType } = require('../lib/build-type'); /** * Map the current version to a format that is compatible with each browser. * * The given version number is assumed to be a SemVer version number. Additionally, if the version * has a prerelease component, it is assumed to have the format ". { const versionParts = [major, minor, patch]; const browserSpecificVersion = {}; if (prerelease) { if (platform === 'firefox') { versionParts[2] = `${versionParts[2]}${buildType}${buildVersion}`; } else { versionParts.push(buildVersion); browserSpecificVersion.version_name = version; } } browserSpecificVersion.version = versionParts.join('.'); platformMap[platform] = browserSpecificVersion; return platformMap; }, {}); } /** * Log an error to the console. * * This function includes a workaround for a SES bug that results in errors * being printed to the console as `{}`. The workaround is to print the stack * instead, which does work correctly. * * @see {@link https://github.com/endojs/endo/issues/944} * @param {Error} error - The error to print */ function logError(error) { console.error(error.stack || error); } module.exports = { getBrowserVersionMap, logError, };