@@ -4,10 +4,13 @@ import grayMatter from "gray-matter"
4
4
import {
5
5
getGitHubStats ,
6
6
type GitHubInfo ,
7
- } from "../scripts/sort-libraries/get-github-stats"
7
+ } from "../sort-libraries/get-github-stats"
8
+
9
+ const DATA_PATH = new URL ( "./github-stats.json" , import . meta. url ) . pathname
10
+ const CODE_DIR = new URL ( "../../src/code" , import . meta. url ) . pathname
8
11
9
12
async function main ( ) {
10
- const filePaths = await fg ( "./src/code/ **/*.md" )
13
+ const filePaths = await fg ( "./**/*.md" , { cwd : CODE_DIR , absolute : true } )
11
14
12
15
const errors : Error [ ] = [ ]
13
16
@@ -57,8 +60,7 @@ async function main() {
57
60
// If it errored for some reason, we don't do anything.
58
61
// If we got it, we overwrite.
59
62
{
60
- const dataPath = "./src/github-stats.json"
61
- const data = await fs . readFile ( dataPath , "utf8" )
63
+ const data = await fs . readFile ( DATA_PATH , "utf8" )
62
64
const existingStats = JSON . parse ( data ) as Record < string , object >
63
65
64
66
const result : Record < string , object > = { }
@@ -79,7 +81,7 @@ async function main() {
79
81
result [ repoName ] = newState . get ( repoName ) !
80
82
}
81
83
82
- await fs . writeFile ( dataPath , JSON . stringify ( result , null , 2 ) )
84
+ await fs . writeFile ( DATA_PATH , JSON . stringify ( result , null , 2 ) )
83
85
}
84
86
}
85
87
0 commit comments