-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.ts
More file actions
24 lines (20 loc) · 745 Bytes
/
commit.ts
File metadata and controls
24 lines (20 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { readFileSync, writeFileSync } from 'node:fs'
export function commit() {
const coverage = readFileSync('./coverage.txt', 'utf8').split(':')[1].split('\n')[0]
console.log('🚀 -> coverage', coverage)
const readme = readFileSync('./README.md', 'utf8')
const coverageStatus = `Total of coverage: ${coverage}`
const readmeWithCoverage = readme.replace(/(.*total of coverage .*\n)/, `$1${coverageStatus}\n`)
console.log('🚀 -> readmeWithCoverage', readmeWithCoverage)
// const commit = {
// message: 'Update coverage badge',
// content: readmeWithCoverage
// }
try {
writeFileSync('./README.md', readmeWithCoverage)
} catch (e) {
console.log('🚀 -> error', e)
}
console.log(commit)
}
commit()