-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-github.js
More file actions
43 lines (37 loc) · 1.01 KB
/
Copy pathget-github.js
File metadata and controls
43 lines (37 loc) · 1.01 KB
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
43
// @ts-check
import querystring from 'node:querystring'
import fs from "node:fs";
import userStats from './github-readme-stats/api/index.js';
import repoStats from './github-readme-stats/api/pin.js';
(async () => {
const TYPE = process.argv[2] ?? 'user';
const FILE = process.argv[3] ?? 'images/rkodey-test.svg';
const QUERY = process.argv[4] ?? 'username=rkodey';
const query = querystring.parse(QUERY);
const noop = () => {};
console.log(`get-github ${TYPE} ${FILE}`);
/**
* @param { string } svg
*/
const writeFile = (svg) => {
// const svg = (/^\s*(.*?)\s*$/is.exec(res) || [])[1];
fs.writeFileSync(FILE, svg)
}
if (TYPE === 'user') {
await userStats({ query },
{
setHeader : noop,
send : writeFile,
});
}
else if (TYPE === 'repo') {
await repoStats({ query },
{
setHeader : noop,
send : writeFile,
});
}
else {
console.log(`Unknown type [${TYPE}]`);
}
})();