mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
28 lines
778 B
TypeScript
28 lines
778 B
TypeScript
import { promises as fs } from 'fs'
|
|
import { $fetch } from 'ohmyfetch'
|
|
|
|
interface Contributor {
|
|
login: string
|
|
}
|
|
|
|
async function fetchContributors(page = 1) {
|
|
const collaborators: string[] = []
|
|
const data = await $fetch<Contributor[]>(`https://api.github.com/repos/vitest-dev/vitest/contributors?per_page=100&page=${page}`, {
|
|
method: 'get',
|
|
headers: {
|
|
'content-type': 'application/json',
|
|
},
|
|
}) || []
|
|
collaborators.push(...data.map(i => i.login))
|
|
if (data.length === 100)
|
|
collaborators.push(...(await fetchContributors(page + 1)))
|
|
return collaborators
|
|
}
|
|
|
|
async function generate() {
|
|
const collaborators = await fetchContributors()
|
|
await fs.writeFile('./docs/contributors.json', JSON.stringify(collaborators, null, 2), 'utf8')
|
|
}
|
|
|
|
generate()
|