Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// define the urls
let releaseUrl;
if (gitTemplate && gitBranch) {
const lastRelease = releases[0];
if (lastRelease) {
releaseUrl = gitTemplate.replace('[prev]', `v${lastRelease.version}`).replace('[next]', `v${version}`);
}
// in the future the template v[version] could be defined by the user, maybe?
unreleased.url = gitTemplate.replace('[prev]', `v${version}`).replace('[next]', gitBranch);
}
const newRelease = createRelease(
{
identifier: version.toLowerCase(),
version,
url: releaseUrl,
yanked: isYanked,
date
},
changes
);
tree.children = [preface, unreleased, newRelease, ...releases];
return tree;
}
function compile(tree, file) {
const preface = select('preface', tree);
if (preface && !overwrite) {
file.fail(new Error('The changelog already exists.'), preface, 'addPreface');
}
tree.children = [
createPreface(parse(tplPreface)),
createRelease({
identifier: 'unreleased',
version: 'Unreleased',
unreleased: true
})
];
return tree;
}