forked from EddieHubCommunity/awesome-github-profiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.js
42 lines (33 loc) · 783 Bytes
/
generate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const fs = require("fs");
const path = require("path");
fs.readdir(
path.join(__dirname, "profiles"),
{
withFileTypes: true,
},
(err, files) => {
if (err) {
throw err;
}
const profiles = [];
fs.mkdir(path.join(__dirname, ".cache"), { recursive: true }, () => {});
files.forEach((file) => {
const profile = require(path.join(__dirname, "profiles", file.name));
profiles.push(profile);
});
const sorted = profiles.sort((a, b) => {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
});
fs.writeFile(
path.join(__dirname, ".cache", "data.json"),
JSON.stringify(sorted),
(err) => {
if (err) {
throw err;
}
}
);
}
);