Skip to content

Commit 3ab6b03

Browse files
committed
Fixes errors in prep script
1 parent 09ae8b1 commit 3ab6b03

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

scripts/prep-release.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ts-check
12
import { exec } from 'child_process';
23
import { readFileSync, writeFileSync } from 'fs';
34
import { createInterface } from 'readline';
@@ -15,15 +16,17 @@ let data = readFileSync(changelogPath, 'utf8');
1516

1617
// Find the current version number
1718
const match = /\[unreleased\]: https:\/\/github\.com\/gitkraken\/vscode-gitlens\/compare\/v(.+)\.\.\.HEAD/.exec(data);
18-
const currentVersion = match?.[1];
19+
let currentVersion = match?.[1];
1920
if (currentVersion == null || versionRegex.test(currentVersion) === false) {
2021
console.error('Unable to find current version number.');
2122
currentVersion = '0.0.0';
2223
}
2324

2425
// Create readline interface for getting input from user
2526
const rl = createInterface({
27+
// @ts-ignore
2628
input: process.stdin,
29+
// @ts-ignore
2730
output: process.stdout,
2831
});
2932

@@ -50,10 +53,15 @@ rl.question(`Enter the new version number (format x.x.x, current is ${currentVer
5053
// Add the new version header below the ## [Unreleased] header
5154
data = data.replace('## [Unreleased]', newVersionHeader);
5255

53-
const unreleasedLink = match[0].replace(/\/compare\/v(.+?)\.\.\.HEAD/, `/compare/v${version}...HEAD`);
56+
if (match == null) {
57+
// Add the [unreleased]: line
58+
data += `\n[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/v${version}...HEAD`;
59+
} else {
60+
const unreleasedLink = match[0].replace(/\/compare\/v(.+?)\.\.\.HEAD/, `/compare/v${version}...HEAD`);
5461

55-
// Update the [unreleased]: line
56-
data = data.replace(match[0], `${unreleasedLink}\n${newVersionLink}`);
62+
// Update the [unreleased]: line
63+
data = data.replace(match[0], `${unreleasedLink}\n${newVersionLink}`);
64+
}
5765

5866
// Writing the updated version data to CHANGELOG
5967
writeFileSync(changelogPath, data);

0 commit comments

Comments
 (0)