@@ -88,18 +88,18 @@ gulp.task('updateChangelog', async (): Promise<void> => {
8888 // Find all the headers in the changelog (and their line numbers)
8989 const [ currentHeaderLine , currentVersion ] = findNextVersionHeaderLine ( changelogLines ) ;
9090 if ( currentHeaderLine === - 1 ) {
91- throw new Error ( 'Could not find the current header in the changelog. ' ) ;
91+ throw new Error ( 'Could not find the current header in the CHANGELOG ' ) ;
9292 }
9393
9494 console . log ( `Adding PRs for ${ currentVersion } to CHANGELOG` ) ;
9595
9696 const [ previousHeaderLine , previousVersion ] = findNextVersionHeaderLine ( changelogLines , currentHeaderLine + 1 ) ;
9797 if ( previousHeaderLine === - 1 ) {
98- throw new Error ( 'Could not find the previous header in the changelog. ' ) ;
98+ throw new Error ( 'Could not find the previous header in the CHANGELOG ' ) ;
9999 }
100100
101101 const presentPrIds = getPrIdsBetweenHeaders ( changelogLines , currentHeaderLine , previousHeaderLine ) ;
102- console . log ( `PRs [#${ presentPrIds . join ( ', #' ) } ] already in the changelog. ` ) ;
102+ console . log ( `PRs [#${ presentPrIds . join ( ', #' ) } ] already in the CHANGELOG ` ) ;
103103
104104 const versionTags = await findTagsByVersion ( previousVersion ! ) ;
105105 if ( versionTags . length === 0 ) {
@@ -110,7 +110,7 @@ gulp.task('updateChangelog', async (): Promise<void> => {
110110 const versionTag = versionTags . pop ( ) ;
111111 console . log ( `Using tag ${ versionTag } for previous version ${ previousVersion } ` ) ;
112112
113- console . log ( `Generating PR list from ${ versionTag } to HEAD... ` ) ;
113+ console . log ( `Generating PR list from ${ versionTag } to HEAD` ) ;
114114 const currentPrs = await generatePRList ( versionTag ! , 'HEAD' ) ;
115115
116116 const newPrs = [ ] ;
@@ -122,14 +122,21 @@ gulp.task('updateChangelog', async (): Promise<void> => {
122122
123123 const prId = match [ 1 ] ;
124124 if ( presentPrIds . includes ( prId ) ) {
125- console . log ( `PR #${ prId } is already present in the changelog. ` ) ;
125+ console . log ( `PR #${ prId } is already present in the CHANGELOG ` ) ;
126126 continue ;
127127 }
128128
129- console . log ( `Adding new PR to changelog : ${ pr } ` ) ;
129+ console . log ( `Adding new PR to CHANGELOG : ${ pr } ` ) ;
130130 newPrs . push ( pr ) ;
131131 }
132132
133+ if ( newPrs . length === 0 ) {
134+ console . log ( 'No new PRs to add to the CHANGELOG' ) ;
135+ return ;
136+ }
137+
138+ console . log ( `Writing ${ newPrs . length } new PRs to the CHANGELOG` ) ;
139+
133140 changelogLines . splice ( currentHeaderLine + 1 , 0 , ...newPrs ) ;
134141 fs . writeFileSync ( changelogPath , changelogLines . join ( os . EOL ) ) ;
135142} ) ;
0 commit comments