chore: add prettier

This commit is contained in:
Federico Grandi
2020-11-29 17:51:26 +01:00
parent 3ed8463058
commit 3140d34146
8 changed files with 290 additions and 154 deletions

View File

@@ -6,15 +6,19 @@ function path(...segments: string[]) {
}
const README = fs.readFileSync(path('README.md'), { encoding: 'utf8' }),
{ contributors } = JSON.parse(fs.readFileSync(path('.all-contributorsrc'), { 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('[![All Contributors](https://img.shields.io/badge/all_contributors-')
const updatedREADME = README.split('\n')
.map((line) =>
line.startsWith(
'[![All Contributors](https://img.shields.io/badge/all_contributors-'
)
? `[![All Contributors](https://img.shields.io/badge/all_contributors-${contributors.length}-orange.svg?style=flat)](#contributors-)`
: line
).join('\n')
)
.join('\n')
fs.writeFileSync(path('README.md'), updatedREADME)