forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangelog.js
executable file
·43 lines (36 loc) · 1.27 KB
/
changelog.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
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
'use strict';
/**
* Just a small command-line wrapper around the conventional-changelog npm module
* (https://www.npmjs.com/package/conventional-changelog), which also prepends
* changes to CHANGELOG.md.
*
* Appends CHANGELOG.md with the changes between tag and HEAD.
* NOTE: only `fix`, `feat`, `perf` and `revert` commits are used
* see: https://github.com/conventional-changelog/conventional-changelog/blob/v0.2.1/presets/angular.js#L24
*/
var fs = require('fs');
var cl = require('conventional-changelog');
const exec = require('child_process').exec;
var changelogStream = fs.createWriteStream('CHANGELOG-delta.md');
if (process.argv.length < 3) {
// eslint-disable-next-line no-console
console.log('Usage: ./scripts/publish/changelog.js <start-tag>');
process.exit(-1);
}
var config = {
preset: 'angular',
releaseCount: 1
};
var prependDelta = function() {
exec('cat CHANGELOG-delta.md CHANGELOG.md > CHANGELOG-new.md;' +
'mv CHANGELOG-new.md CHANGELOG.md;' +
'rm CHANGELOG-delta.md');
}
cl(config, null, { from: process.argv[2] })
.on('error', function(err) {
// eslint-disable-next-line no-console
console.error('Failed to generate changelog: ' + err);
})
.pipe(changelogStream)
.on('close', prependDelta);