Skip to content

Commit 4486435

Browse files
committed
fix(core): extract correct version from changelog
1 parent bdb6ff2 commit 4486435

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

packages/core/src/change-log.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,23 @@ export async function extractLastRelease(input: string | string[] | Iterable<str
104104
lines = chunk.toString('utf8').split(/\n/)
105105

106106
for (line of lines) {
107-
const matches = line.match(versionHeaderRegex)
108-
109-
if (matches) {
110-
[, version] = matches
107+
const versionMatch = line.match(versionHeaderRegex)
111108

109+
if (versionMatch) {
112110
if (inLastChanges) {
113111
break top
114112
}
115113

114+
[, version] = versionMatch
116115
inLastChanges = true
117116

118-
const match = line.match(tagsRegex)
117+
const tagsMatch = line.match(tagsRegex)
119118

120-
if (match) {
119+
if (tagsMatch) {
121120
[
122121
, previousTag,
123122
nextTag
124-
] = match
123+
] = tagsMatch
125124
}
126125

127126
continue

packages/core/src/changelog.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('core', () => {
7070
7171
* **browserslist-config:** update queries, add esm queries ([3031c6b](https://github.com/TrigenSoftware/scripts/commit/3031c6b322330be57654bdebc1012bddc20e7972))",
7272
"previousTag": "v8.0.0-alpha.1",
73-
"version": "8.0.0-alpha.1",
73+
"version": "8.0.0-alpha.2",
7474
}
7575
`)
7676

@@ -83,7 +83,7 @@ describe('core', () => {
8383
8484
* **cli:** fix config file loading ([8603c2f](https://github.com/TrigenSoftware/simple-github-release/commit/8603c2fde4aeb53619fae8bb9feba53093f51c65))",
8585
"previousTag": "v0.0.1-0",
86-
"version": "0.0.1-0",
86+
"version": "0.0.1-1",
8787
}
8888
`)
8989

@@ -105,7 +105,7 @@ describe('core', () => {
105105
### Removed
106106
- Section about "changelog" vs "CHANGELOG".",
107107
"previousTag": "",
108-
"version": "0.3.0",
108+
"version": "1.0.0",
109109
}
110110
`)
111111
})

0 commit comments

Comments
 (0)