forked from vuejs/vue-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenChangelog.js
34 lines (28 loc) · 837 Bytes
/
genChangelog.js
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
34
const fs = require('fs')
const path = require('path')
const execa = require('execa')
async function genNewRelease () {
if (process.env.GIT_E2E_SETUP) {
return 'skipped for e2e testing'
}
const nextVersion = require('../lerna.json').version
const { stdout } = await execa(require.resolve('lerna-changelog/bin/cli'), [
'--next-version',
nextVersion
])
return stdout
}
const gen = (module.exports = async () => {
const newRelease = await genNewRelease()
const changelogPath = path.resolve(__dirname, '../CHANGELOG.md')
const newChangelog =
newRelease + '\n\n\n' + fs.readFileSync(changelogPath, { encoding: 'utf8' })
fs.writeFileSync(changelogPath, newChangelog)
delete process.env.PREFIX
})
if (require.main === module) {
gen().catch(err => {
console.error(err)
process.exit(1)
})
}