File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ const { parser } = require ( "keep-a-changelog" ) ;
2+ const fs = require ( "fs" ) ;
3+
4+ // Show and release and its changes
5+ function show ( version , options ) {
6+ // Read changelog file
7+ const changelog = parser ( fs . readFileSync ( options . file , options . encoding ) ) ;
8+ changelog . format = options . format ;
9+ changelog . sortReleases ( ) ;
10+
11+ // Find release
12+ let release ;
13+ switch ( version ) {
14+ case "latest" :
15+ release = changelog . releases . find ( ( release ) =>
16+ release . date && release . version
17+ ) ;
18+ break ;
19+ case "unreleased" :
20+ version = undefined ;
21+ default :
22+ release = changelog . findRelease ( version ) ;
23+ }
24+ if ( ! release ) {
25+ throw new Error ( `release ${ version } not found` ) ;
26+ }
27+
28+ // Print changes
29+ console . log ( release . toString ( changelog ) ) ;
30+ }
31+
32+ module . exports = { show } ;
You can’t perform that action at this time.
0 commit comments