Skip to content

Commit 1ae5361

Browse files
authored
Update update-readme.js
1 parent 0c171ca commit 1ae5361

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

update-readme.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (!sectionMatch) {
1717
let pluginsListContent = sectionMatch[1].trim();
1818

1919
// Regex to match individual plugins in the extracted section
20-
const pluginRegex = /- ### (.*?).*?\s*<br>/g;
20+
const pluginRegex = /- ### (.*?).*? <br>/g;
2121

2222
// Map to hold parsed plugin entries from the extracted section
2323
const readmePlugins = new Map();
@@ -40,7 +40,20 @@ parsedBadges.forEach(({ name, repo, latestReleaseUrl }) => {
4040
const normalizedPluginName = name.trim().toLowerCase(); // Normalize name for matching
4141
if (readmePlugins.has(normalizedPluginName)) {
4242
console.log(`Matching plugin found in README for ${name}`);
43-
changesMade = true; // Simulate a change to trigger output (real update logic omitted for clarity)
43+
44+
// Construct the expected download badge URL
45+
const expectedBadgeUrl = `https://img.shields.io/github/downloads/${repo}/total`;
46+
47+
// Replace the existing download URL in the README
48+
const updatedContent = readmeContent.replace(
49+
new RegExp(`\!\GitHub Downloads \all releases\\\.*?\\\.*?\`, 'g'),
50+
`[![GitHub Downloads (all releases)](${expectedBadgeUrl})](${latestReleaseUrl})`
51+
);
52+
53+
if (updatedContent !== readmeContent) {
54+
readmeContent = updatedContent;
55+
changesMade = true;
56+
}
4457
} else {
4558
console.log(`No matching plugin found in README for ${name}`);
4659
}

0 commit comments

Comments
 (0)