File tree Expand file tree Collapse file tree 4 files changed +37
-5
lines changed
Expand file tree Collapse file tree 4 files changed +37
-5
lines changed Original file line number Diff line number Diff line change 11#! /bin/sh
22
3- node scripts/check-tag.js
3+ node scripts/check-tag.js
4+ node scripts/check-readme.js
Original file line number Diff line number Diff line change 11{
22 "name" : " wing-companion" ,
3- "version" : " 2.2.3 " ,
3+ "version" : " 2.2.4-beta.1 " ,
44 "main" : " dist/index.js" ,
55 "type" : " module" ,
66 "scripts" : {
Original file line number Diff line number Diff line change 1+ import * as fs from 'fs'
2+ import { exit } from 'process'
3+
4+ let pkg
5+ try {
6+ pkg = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) )
7+ } catch {
8+ throw new Error ( 'Cannot parse package.json' )
9+ }
10+
11+ const pkgVersion = pkg . version
12+
13+ if ( pkgVersion . includes ( 'alpha' ) || pkgVersion . includes ( 'beta' ) || pkgVersion . includes ( 'rc' ) ) {
14+ console . log ( `Version '${ pkgVersion } ' is a pre-release, skipping README check` )
15+ exit ( 0 )
16+ }
17+
18+ let readme = ''
19+ try {
20+ readme = fs . readFileSync ( 'README.md' , 'utf8' )
21+ } catch {
22+ throw new Error ( 'Cannot read README.md' )
23+ }
24+
25+ if ( ! readme . includes ( `## ${ pkgVersion } ` ) ) {
26+ throw new Error ( `README.md does not contain version '${ pkgVersion } '` )
27+ }
28+
29+ console . log ( `README.md contains version '${ pkgVersion } '` )
Original file line number Diff line number Diff line change @@ -21,8 +21,10 @@ if (!tag) {
2121 throw new Error ( 'No git tag found on this branch' )
2222}
2323
24- if ( ! / ^ v \d + ( \. \d + ) { 2 , 3 } $ / . test ( tag ) ) {
25- throw new Error ( `Latest tag '${ tag } ' does not match vX.Y.Z or vX.Y.Z.W` )
24+ const VERSION_RE = / ^ v \d + \. \d + \. \d + ( - ( a l p h a | b e t a | r c ) ( \. \d + ) ? ) ? $ /
25+
26+ if ( ! VERSION_RE . test ( tag ) ) {
27+ throw new Error ( `Latest tag '${ tag } ' does not match vX.Y.Z[-(alpha|beta|rc)[.n]]` )
2628}
2729
2830let pkg
@@ -36,7 +38,7 @@ const pkgVersion = pkg.version
3638const tagVersion = tag . slice ( 1 )
3739
3840if ( pkgVersion !== tagVersion ) {
39- throw new Error ( `ERROR: package.json version (${ pkgVersion } ) does not match git tag (${ tag } )` )
41+ throw new Error ( `package.json version (${ pkgVersion } ) does not match git tag (${ tag } )` )
4042}
4143
4244console . log ( `Git tag '${ tag } ' matches package.json version '${ pkgVersion } '` )
You can’t perform that action at this time.
0 commit comments