mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-25 11:14:05 +00:00
* Create update-contributors.js * move `## Contributors` out of `<!--contributors-->` * use execa * Update bin/update-contributors.js Co-Authored-By: Renée Kooi <renee@kooi.me> * yes, it’s not pretty, but it works? * switch to execa again: showLogin --> showlogin thanks @goto-bus-stop Co-authored-by: Renée Kooi <renee@kooi.me>
35 lines
982 B
JavaScript
35 lines
982 B
JavaScript
const execa = require('execa')
|
||
const fs = require('fs')
|
||
|
||
const README_FILE_NAME = 'README.md'
|
||
|
||
async function updateContributorsListInReadme () {
|
||
const readme = fs.readFileSync(README_FILE_NAME, 'utf-8')
|
||
const args = [
|
||
'--owner', 'transloadit',
|
||
'--repo', 'uppy',
|
||
'--cols', '6',
|
||
'--format', 'md',
|
||
'--showlogin', 'true',
|
||
'--sortOrder', 'desc'
|
||
]
|
||
|
||
if (process.env.GITHUB_TOKEN) {
|
||
args.push('--authToken', process.env.GITHUB_TOKEN)
|
||
}
|
||
|
||
const { stdout } = await execa('githubcontrib', args, { encoding: 'utf-8' })
|
||
console.log(stdout)
|
||
if (stdout === '' || stdout === null) {
|
||
console.log('Empty response from githubcontrib. GitHub’s rate limit?')
|
||
return
|
||
}
|
||
|
||
const readmeWithUpdatedContributors = readme.replace(
|
||
/<!--contributors-->[\s\S]+<!--\/contributors-->/,
|
||
`<!--contributors-->\n${stdout}\n<!--/contributors-->`
|
||
)
|
||
fs.writeFileSync(README_FILE_NAME, readmeWithUpdatedContributors)
|
||
}
|
||
|
||
updateContributorsListInReadme()
|