git ssb

1+

Daan Patchwork / patchwork



Tree: 58ab0241031aa549a35cce1e678c27065ae66221

Files: 58ab0241031aa549a35cce1e678c27065ae66221 / scripts / release-notes.js

936 bytesRaw
1const fs = require('fs')
2const path = require('path')
3
4const version = process.env.npm_package_version
5
6if (version == null) {
7 throw new Error('no version found, are you running from npm? try `npm run release-notes`')
8}
9
10const template = fs.readFileSync(path.join(__dirname, '..', 'docs', 'release-notes-template.md'), 'utf8')
11const changelog = fs.readFileSync(path.join(__dirname, '..', 'docs', 'CHANGELOG.md'), 'utf8')
12
13let record = false
14const lines = changelog.split('\n')
15
16const relevantLines = lines.reduce((acc, cur) => {
17 if (cur.startsWith('## ')) {
18 if (cur.startsWith(`## v${version}`)) {
19 record = true
20 return acc
21 } else {
22 record = false
23 return acc
24 }
25 }
26
27 if (record) {
28 acc.push(cur)
29 }
30
31 return acc
32}, [])
33
34const changes = relevantLines.join('\n')
35
36const releaseNotes = template
37 .replace(/\$\$VERSION/g, version)
38 .replace(/\$\$CHANGES/g, changes)
39
40console.log(releaseNotes)
41

Built with git-ssb-web