File tree 1 file changed +41
-0
lines changed
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
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 ) ;
You can’t perform that action at this time.
0 commit comments