25 lines
789 B
TypeScript
25 lines
789 B
TypeScript
import * as fs from 'fs'
|
|
import { resolve } from 'path'
|
|
|
|
function path(...segments: string[]) {
|
|
return resolve(__dirname, '..', ...segments)
|
|
}
|
|
|
|
const README = fs.readFileSync(path('README.md'), { encoding: 'utf8' }),
|
|
{ contributors } = JSON.parse(
|
|
fs.readFileSync(path('.all-contributorsrc'), { encoding: 'utf8' })
|
|
)
|
|
if (!(contributors instanceof Array)) throw new Error('Invalid config file')
|
|
|
|
const updatedREADME = README.split('\n')
|
|
.map((line) =>
|
|
line.startsWith(
|
|
'[
|
|
? `[](#contributors-)`
|
|
: line
|
|
)
|
|
.join('\n')
|
|
|
|
fs.writeFileSync(path('README.md'), updatedREADME)
|