Skip to content

Commit a4c588e

Browse files
committed
Generate CONTRIBUTORS.md
1 parent e512260 commit a4c588e

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111

1212
rules: {
1313
"@typescript-eslint/no-var-requires": "off",
14+
"@typescript-eslint/no-unsafe-assignment": "off",
1415
},
1516
},
1617
],

CONTRIBUTORS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Contributors
2+
3+
- ![paleite](https://avatars.githubusercontent.com/u/4430528?v=4&s=50) [paleite](https://github.com/paleite)
4+
- ![DaVarga](https://avatars.githubusercontent.com/u/3964986?v=4&s=50) [DaVarga](https://github.com/DaVarga)
5+
- ![IsLand-x](https://avatars.githubusercontent.com/u/50228788?v=4&s=50) [IsLand-x](https://github.com/IsLand-x)
6+
- ![ezequiel](https://avatars.githubusercontent.com/u/368069?v=4&s=50) [ezequiel](https://github.com/ezequiel)
7+
- ![burtonator](https://avatars.githubusercontent.com/u/45447?v=4&s=50) [burtonator](https://github.com/burtonator)
8+
- ![flupke](https://avatars.githubusercontent.com/u/188962?v=4&s=50) [flupke](https://github.com/flupke)
9+
- ![mathieutu](https://avatars.githubusercontent.com/u/11351322?v=4&s=50) [mathieutu](https://github.com/mathieutu)
10+
- ![JosephLing](https://avatars.githubusercontent.com/u/8035792?v=4&s=50) [JosephLing](https://github.com/JosephLing)

generate-contributors.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const https = require("https");
2+
const fs = require("fs");
3+
4+
const options = {
5+
hostname: "api.github.com",
6+
port: 443,
7+
path: "/repos/paleite/eslint-plugin-diff/contributors",
8+
method: "GET",
9+
headers: {
10+
"User-Agent": "node.js", // GitHub requires a user-agent header
11+
},
12+
};
13+
14+
let rawData = "";
15+
16+
const req = https.request(options, (res) => {
17+
res.setEncoding("utf8");
18+
res.on("data", (chunk) => {
19+
rawData += chunk;
20+
});
21+
res.on("end", () => {
22+
try {
23+
/** @type {{login: string, avatar_url: string, html_url: string}[]} */
24+
const parsedData = JSON.parse(rawData);
25+
26+
const contributorsList = parsedData
27+
.filter(({ login }) => !login.includes("[bot]"))
28+
.map(
29+
(contributor) =>
30+
`- ![${contributor.login}](${contributor.avatar_url}&s=50) [${contributor.login}](${contributor.html_url})`
31+
);
32+
33+
fs.writeFileSync(
34+
"CONTRIBUTORS.md",
35+
["# Contributors", contributorsList.join("\n")].join("\n\n")
36+
);
37+
} catch (e) {
38+
console.error(e.message);
39+
}
40+
});
41+
});
42+
43+
req.on("error", (e) => {
44+
console.error(`Problem with request: ${e.message}`);
45+
});
46+
47+
req.end();

0 commit comments

Comments
 (0)