-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrender.ts
33 lines (22 loc) · 840 Bytes
/
render.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { execSync } from 'node:child_process'
import { readFileSync, writeFileSync } from 'node:fs'
import { renderCategory } from './lib/helpers'
import { source } from './source'
const delimiterStart = '[//]: <> (START_GENERATED_SECTION)'
const delimiterEnd = '[//]: <> (END_GENERATED_SECTION)'
const readme = readFileSync('./README.md', 'utf8')
const firstPart = readme.split(delimiterStart)[0]
const secondPart = readme.split(delimiterEnd)[1]
const result: string[] = []
result.push(firstPart)
result.push(delimiterStart)
for (const category of source) {
const strings = renderCategory(category)
result.push(strings.join('\n'))
}
result.push(delimiterEnd)
result.push(secondPart)
console.log(result.join('\n'))
writeFileSync('./README.md', result.join('\n'))
execSync('prettier --write ./README.md')
console.log('Done!')