renovate/lib/versioning/index.js
2018-12-13 05:29:11 +01:00

26 lines
601 B
JavaScript

const supportedSchemes = require('../config/definitions')
.getOptions()
.find(option => option.name === 'versionScheme').allowedValues;
const schemes = {};
for (const scheme of supportedSchemes) {
schemes[scheme] = require('./' + scheme); // eslint-disable-line
}
module.exports = {
get,
};
function get(versionScheme) {
if (!versionScheme) {
logger.debug('Missing versionScheme');
return schemes.semver;
}
const scheme = schemes[versionScheme];
if (!scheme) {
logger.warn({ versionScheme }, 'Unknown version scheme');
return schemes.semver;
}
return scheme;
}