8000 chore: adding a changelog script, from Angular · mikebellcoder/angular-cli@1fa0c31 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1fa0c31

Browse files
committed
chore: adding a changelog script, from Angular
1 parent 916c8d2 commit 1fa0c31

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

scripts/publish/changelog.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
/**
5+
* Just a small command-line wrapper around the conventional-changelog npm module
6+
* (https://www.npmjs.com/package/conventional-changelog), which also prepends
7+
* changes to CHANGELOG.md.
8+
*
9+
* Appends CHANGELOG.md with the changes between tag and HEAD.
10+
* NOTE: only `fix`, `feat`, `perf` and `revert` commits are used
11+
* see: https://github.com/conventional-changelog/conventional-changelog/blob/v0.2.1/presets/angular.js#L24
12+
*/
13+
14+
var fs = require('fs');
15+
var cl = require('conventional-changelog');
16+
const exec = require('child_process').exec;
17+
18+
var changelogStream = fs.createWriteStream('CHANGELOG-delta.md');
19+
20+
if (process.argv.length < 3) {
21+
console.log('Usage: ./scripts/publish/changelog.js <start-tag>');
22+
process.exit(-1);
23+
}
24+
25+
var config = {
26+
preset: 'angular',
27+
releaseCount: 1,
28+
};
29+
30+
var prependDelta = function() {
31+
exec('cat CHANGELOG-delta.md CHANGELOG.md > CHANGELOG-new.md;' +
32+
'mv CHANGELOG-new.md CHANGELOG.md;' +
33+
'rm CHANGELOG-delta.md');
34+
}
35+
36+
cl(config, null, { from: process.argv[2] })
37+
.on('error', function(err) {
38+
console.error('Failed to generate changelog: ' + err);
39+
})
40+
.pipe(changelogStream)
41+
.on('close', prependDelta);

0 commit comments

Comments
 (0)
0