semantic-release-major-tag
Version:
Create and update major version tags during release
26 lines (25 loc) • 995 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const validateCustomTagsSetting = (customTags) => {
if (!customTags) {
// No error message as the setting can just be simply not provided
return;
}
if (!Array.isArray(customTags)) {
throw new Error(`customTags setting is not an array! customTags: ${customTags}`);
}
if (!customTags.every((i) => typeof i === 'string')) {
throw new Error(`customTags setting does not contain strings in array! customTags: ${customTags}`);
}
return customTags;
};
const prepareTags = (version, pluginConfig) => {
const customTags = validateCustomTagsSetting(pluginConfig.customTags);
const tagsFormat = customTags || ['v${major}'];
const [major, minor, patch] = version.split('.');
return tagsFormat.map((tag) => tag
.replace('${major}', major)
.replace('${minor}', minor)
.replace('${patch}', patch));
};
exports.default = prepareTags;