Skip to content

Commit d8ab6f2

Browse files
authored
Merge pull request #14 from brown9804/testing-if-all-markdowns
search for all markdowns
2 parents 857cb5c + 57247d7 commit d8ab6f2

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

metrics.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"total_views": 1022,
3-
"lastUpdated": "2025-07-11T19:59:55.567Z"
3+
"lastUpdated": "2025-07-11T20:07:49.421Z"
44
}

update_repo_views_counter.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,23 @@ function updateMetricsFile(total_views) {
4242
function updateMarkdownBadges(total_views) {
4343
const refreshDate = new Date().toISOString().split('T')[0];
4444
const badgeRegex = /<!-- START BADGE -->[\s\S]*?<!-- END BADGE -->/g;
45-
45+
4646
const badgeBlock = `<!-- START BADGE -->
4747
<div align="center">
4848
<img src="https://img.shields.io/badge/Total%20views-${total_views}-limegreen" alt="Total views">
4949
<p>Refresh Date: ${refreshDate}</p>
5050
</div>
5151
<!-- END BADGE -->`;
5252

53-
const markdownFiles = findMarkdownFiles('.');
53+
const markdownFiles = findMarkdownFiles('.'); // Find all Markdown files in the directory
5454
markdownFiles.forEach(file => {
5555
let content = fs.readFileSync(file, 'utf-8');
56-
    if (badgeRegex.test(content)) {
56+
if (badgeRegex.test(content)) {
5757
const updated = content.replace(badgeRegex, badgeBlock);
5858
fs.writeFileSync(file, updated);
5959
console.log(`Updated badge in ${file}`);
60+
} else {
61+
console.log(`Badge block not found in ${file}`);
6062
}
6163
});
6264
}
@@ -68,9 +70,9 @@ function findMarkdownFiles(dir) {
6870
const filePath = path.join(dir, file);
6971
const stat = fs.statSync(filePath);
7072
if (stat && stat.isDirectory()) {
71-
results = results.concat(findMarkdownFiles(filePath));
73+
results = results.concat(findMarkdownFiles(filePath)); // Recursively search subdirectories
7274
} else if (file.endsWith('.md')) {
73-
results.push(filePath);
75+
results.push(filePath); // Add Markdown files to the results
7476
}
7577
});
7678
return results;

0 commit comments

Comments
 (0)