File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1212 "dev" : " tsc --watch" ,
1313 "start" : " node dist/cli.js" ,
1414 "test" : " jest" ,
15+ "preversion" : " node scripts/check-changelog.js" ,
1516 "test:watch" : " jest --watch" ,
1617 "lint" : " eslint 'src/**/*.ts'" ,
1718 "lint:fix" : " eslint 'src/**/*.ts' --fix" ,
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+ const fs = require ( 'fs' ) ;
3+ const path = require ( 'path' ) ;
4+
5+ function fail ( msg ) {
6+ console . error ( `❌ CHANGELOG check failed: ${ msg } ` ) ;
7+ process . exit ( 1 ) ;
8+ }
9+
10+ try {
11+ const pkgPath = path . join ( process . cwd ( ) , 'package.json' ) ;
12+ const changelogPath = path . join ( process . cwd ( ) , 'CHANGELOG.md' ) ;
13+ const pkg = JSON . parse ( fs . readFileSync ( pkgPath , 'utf-8' ) ) ;
14+ const version = pkg . version ;
15+ const changelog = fs . readFileSync ( changelogPath , 'utf-8' ) ;
16+ const header = new RegExp ( `^##\\s+${ version } \\s+—` , 'm' ) ;
17+ if ( ! header . test ( changelog ) ) {
18+ fail ( `CHANGELOG.md does not contain a header for version ${ version } ` ) ;
19+ }
20+ console . log ( `✓ CHANGELOG contains entry for ${ version } ` ) ;
21+ } catch ( e ) {
22+ fail ( e && e . message ? e . message : String ( e ) ) ;
23+ }
24+
25+
You can’t perform that action at this time.
0 commit comments