@@ -15,7 +15,7 @@ if (!sectionMatch) {
1515const pluginsListContent = sectionMatch [ 1 ] . trim ( ) ;
1616
1717// Regex to match individual plugin entries
18- const pluginRegex = / - # # # ( .+ ?) . * ? ! G i t H u b D o w n l o a d s a l l r e l e a s e s ( h t t p s : \/ \/ i m g \. s h i e l d s \. i o \/ g i t h u b \/ d o w n l o a d s \/ .+ ?\/ t o t a l ) ( .+ ?) / g;
18+ const pluginRegex = / - # # # ( .+ ?) \s * ! G i t H u b D o w n l o a d s a l l r e l e a s e s ( h t t p s : \/ \/ i m g \. s h i e l d s \. i o \/ g i t h u b \/ d o w n l o a d s \/ .+ ?\/ t o t a l ) ( .+ ?) / g;
1919const readmePlugins = new Map ( ) ;
2020let match ;
2121
@@ -48,24 +48,25 @@ parsedBadges.forEach(({ name, latestReleaseUrl }) => {
4848
4949 if ( pluginEntry ) {
5050 console . log ( `\nChecking plugin: ${ name } ` ) ;
51- console . log ( `Current download URL: ${ pluginEntry . currentDownloadUrl } ` ) ;
52- console . log ( `Latest release URL: ${ latestReleaseUrl } ` ) ;
51+ console . log ( `Current download URL in README : ${ pluginEntry . currentDownloadUrl } ` ) ;
52+ console . log ( `Latest release URL from badges.json : ${ latestReleaseUrl } ` ) ;
5353
54- const expectedBadgeUrl = `https://img.shields.io/github/downloads/${ name } /total` ;
55-
56- // Check if URLs need updating
54+ // Check if the download URL needs updating
5755 if ( pluginEntry . currentDownloadUrl !== latestReleaseUrl ) {
5856 console . log ( `Updating download URL for ${ name } ` ) ;
57+
58+ const expectedBadgeUrl = `https://img.shields.io/github/downloads/${ name } /total` ;
5959 const newBadge = `[](${ latestReleaseUrl } )` ;
6060
61- // Update the plugin entry in the README
61+ // Construct the old and new plugin entries
6262 const oldEntry = `- ### [${ pluginEntry . pluginName } ] [](${ pluginEntry . currentDownloadUrl } )` ;
6363 const newEntry = `- ### [${ pluginEntry . pluginName } ] ${ newBadge } ` ;
6464
65+ // Replace the old entry with the new one in the README
6566 readmeContent = readmeContent . replace ( oldEntry , newEntry ) ;
6667 changesMade = true ;
6768 } else {
68- console . log ( `No update needed for ${ name } , URLs match. ` ) ;
69+ console . log ( `No update needed for ${ name } ` ) ;
6970 }
7071 } else {
7172 console . log ( `No matching plugin found in README for ${ name } ` ) ;
@@ -74,7 +75,7 @@ parsedBadges.forEach(({ name, latestReleaseUrl }) => {
7475
7576// Write updated README if changes were made
7677if ( changesMade ) {
77- console . log ( '\nChanges detected, updating README...' ) ;
78+ console . log ( 'Changes detected, updating README...' ) ;
7879 fs . writeFileSync ( 'README.md' , readmeContent , 'utf8' ) ;
7980 console . log ( 'README updated successfully.' ) ;
8081} else {
0 commit comments