Skip to content

Commit 053e5f5

Browse files
committed
feat: added followers count
1 parent 49ba754 commit 053e5f5

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ My name is Pulkit. I'm a undergraduate from 🇮🇳
2828

2929
---
3030

31-
### :sparkles: [My followers](https://github.com/Pulkitxm?tab=followers)
31+
<!--START_SECTION:top-followers-heading-->
32+
### :sparkles: [My followers (58)](https://github.com/Pulkitxm?tab=followers)
33+
<!--End_SECTION:top-followers-heading-->
3234

3335
<!--START_SECTION:top-followers-->
3436
<div style="display: flex; justify-content: center; flex-wrap: wrap;"><a href="https://github.com/trinhminhtriet" target="_blank"><img src="https://avatars.githubusercontent.com/u/1650997?v=4" alt="Follower" width="50" height="50" style="border-radius: 50%; margin: 3px;"/></a>

scripts/src/fetchFollowers.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import dotenv from "dotenv";
22
dotenv.config();
33

4-
console.log(process.env.ACCESS_TOKEN);
4+
if(process.env.ACCESS_TOKEN === undefined){
5+
console.error("Please provide ACCESS_TOKEN in .env file");
6+
process.exit(1);
7+
}
58

69
import { Octokit } from "@octokit/rest";
710
import { readFileSync, writeFileSync } from "fs";
@@ -34,8 +37,14 @@ const getLatestFollowers = async () => {
3437

3538
async function main() {
3639
const followers = await getLatestFollowers();
37-
40+
const followersLength = followers.length;
3841
let readme = readFileSync(READMEFILE_PATH, "utf-8");
42+
43+
readme = readme.replace(
44+
/(?<=<!--START_SECTION:top-followers-heading-->\n### :sparkles: \[My followers \()(\d+)(?=\)\])/,
45+
`${followersLength}`
46+
);
47+
3948
readme = readme.replace(
4049
/(?<=<!--START_SECTION:top-followers-->\n)[\s\S]*(?=\n<!--END_SECTION:top-followers-->)/,
4150
`<div style="display: flex; justify-content: center; flex-wrap: wrap;">` +
@@ -47,6 +56,12 @@ async function main() {
4756
.join("\n") +
4857
`</div>`
4958
);
59+
60+
61+
62+
// Update the followers count
63+
64+
5065
writeFileSync(READMEFILE_PATH, readme);
5166
}
5267

0 commit comments

Comments
 (0)