Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions packages/shipjs/src/step/prepare/updateChangelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ export async function prepareParams({
return { args, gitRawCommitsOpts, templateContext };
}

// Wraps a transform function to clone commits before modification.
// This is needed because conventional-changelog-writer freezes commit objects,
// but presets like angular expect to mutate them.
function wrapTransform(originalTransform) {
if (!originalTransform) {
return undefined;
}

return (commit, context) => {
const mutableCommit = JSON.parse(JSON.stringify(commit));

return originalTransform(mutableCommit, context);
};
}

function runConventionalChangelog({
args,
templateContext,
Expand All @@ -165,12 +180,15 @@ function runConventionalChangelog({
}

const { parserOpts, writerOpts } = args.config || {};
const wrappedWriterOpts = writerOpts
? { ...writerOpts, transform: wrapTransform(writerOpts.transform) }
: undefined;
const changelogStream = conventionalChangelogCore(
args,
templateContext,
{ ...gitRawCommitsOpts, path: dir },
parserOpts,
writerOpts,
parserOpts ? { ...parserOpts } : undefined,
wrappedWriterOpts,
{ path: dir, cwd: dir }
).on('error', reject);

Expand Down