Skip to content

Commit 5eb2487

Browse files
sarahdayanclaude
andauthored
fix(changelog): handle frozen commit objects from conventional-changelog-writer (#1046)
Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 447dd87 commit 5eb2487

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

packages/shipjs/src/step/prepare/updateChangelog.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ export async function prepareParams({
152152
return { args, gitRawCommitsOpts, templateContext };
153153
}
154154

155+
// Wraps a transform function to clone commits before modification.
156+
// This is needed because conventional-changelog-writer freezes commit objects,
157+
// but presets like angular expect to mutate them.
158+
function wrapTransform(originalTransform) {
159+
if (!originalTransform) {
160+
return undefined;
161+
}
162+
163+
return (commit, context) => {
164+
const mutableCommit = JSON.parse(JSON.stringify(commit));
165+
166+
return originalTransform(mutableCommit, context);
167+
};
168+
}
169+
155170
function runConventionalChangelog({
156171
args,
157172
templateContext,
@@ -165,12 +180,15 @@ function runConventionalChangelog({
165180
}
166181

167182
const { parserOpts, writerOpts } = args.config || {};
183+
const wrappedWriterOpts = writerOpts
184+
? { ...writerOpts, transform: wrapTransform(writerOpts.transform) }
185+
: undefined;
168186
const changelogStream = conventionalChangelogCore(
169187
args,
170188
templateContext,
171189
{ ...gitRawCommitsOpts, path: dir },
172-
parserOpts,
173-
writerOpts,
190+
parserOpts ? { ...parserOpts } : undefined,
191+
wrappedWriterOpts,
174192
{ path: dir, cwd: dir }
175193
).on('error', reject);
176194

0 commit comments

Comments
 (0)