File tree Expand file tree Collapse file tree
packages/shipjs/src/step/prepare Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
155170function 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
You can’t perform that action at this time.
0 commit comments