Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return changes.reduce((result, { version = 'unreleased', action, group, value }) => {
assert(value, '`value` is required');
const release = select(`release[identifier=${version}]`, tree);
if (!release) {
file.message(`The release "${version}" was not found.`, tree, 'addChanges');
return tree;
}
const actionNode = findActionOrCreate(action, release);
const changeNode = createChange(parse(value));
if (group) {
const groupNode = findGroupOrCreate(group, actionNode);
groupNode.children.push(changeNode);
} else {
actionNode.children.push(changeNode);
}
return tree;
}, tree);
}