Skip to content

Commit ccdd687

Browse files
committedOct 29, 2024·
Minor refactor for readability
1 parent 73e212c commit ccdd687

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed
 

‎index.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { EOL } from 'os';
2-
import fs from 'fs';
1+
import { EOL } from 'node:os';
2+
import fs from 'node:fs';
33
import { Plugin } from 'release-it';
44
import { Bumper } from 'conventional-recommended-bump';
55
import conventionalChangelog from 'conventional-changelog';
@@ -48,20 +48,19 @@ class ConventionalChangelog extends Plugin {
4848
async function getWhatBump() {
4949
if (options.whatBump === false) {
5050
return () => ({ releaseType: null });
51-
} else {
52-
const bumperPreset = await bumper.preset;
51+
}
52+
const bumperPreset = await bumper.preset;
5353

54-
if (bumperPreset === null) return () => ({ releaseType: null });
54+
if (bumperPreset === null) return () => ({ releaseType: null });
5555

56-
return bumperPreset.whatBump || bumperPreset.recommendedBumpOpts.whatBump;
57-
}
56+
return bumperPreset.whatBump || bumperPreset.recommendedBumpOpts.whatBump;
5857
}
5958

60-
const result = await bumper.bump(await getWhatBump());
59+
const recommendation = await bumper.bump(await getWhatBump());
6160

62-
this.debug({ result });
61+
this.debug({ result: recommendation });
6362

64-
let { releaseType } = result;
63+
let { releaseType } = recommendation;
6564

6665
if (increment) {
6766
this.log.warn(`The recommended bump is "${releaseType}", but is overridden with "${increment}".`);
@@ -70,7 +69,9 @@ class ConventionalChangelog extends Plugin {
7069

7170
if (increment && semver.valid(increment)) {
7271
return increment;
73-
} else if (isPreRelease) {
72+
}
73+
74+
if (isPreRelease) {
7475
if (releaseType && (options.strictSemVer || !semver.prerelease(latestVersion))) {
7576
return semver.inc(latestVersion, `pre${releaseType}`, preReleaseId);
7677
}
@@ -91,9 +92,9 @@ class ConventionalChangelog extends Plugin {
9192

9293
if (
9394
lastStableTag &&
94-
(releaseTypeToLastNonPrerelease == 'major' ||
95-
releaseTypeToLastNonPrerelease == 'minor' ||
96-
releaseTypeToLastNonPrerelease == 'patch')
95+
(releaseTypeToLastNonPrerelease === 'major' ||
96+
releaseTypeToLastNonPrerelease === 'minor' ||
97+
releaseTypeToLastNonPrerelease === 'patch')
9798
) {
9899
if (
99100
semver[releaseTypeToLastNonPrerelease](lastStableTag) ==
@@ -104,11 +105,13 @@ class ConventionalChangelog extends Plugin {
104105
}
105106

106107
return semver.inc(latestVersion, 'prerelease', preReleaseId);
107-
} else if (releaseType) {
108+
}
109+
110+
if (releaseType) {
108111
return semver.inc(latestVersion, releaseType, preReleaseId);
109-
} else {
110-
return null;
111112
}
113+
114+
return null;
112115
} catch (err) {
113116
this.debug({ err });
114117
throw err;

0 commit comments

Comments
 (0)
Please sign in to comment.