1
- import { EOL } from 'os' ;
2
- import fs from 'fs' ;
1
+ import { EOL } from 'node: os' ;
2
+ import fs from 'node: fs' ;
3
3
import { Plugin } from 'release-it' ;
4
4
import { Bumper } from 'conventional-recommended-bump' ;
5
5
import conventionalChangelog from 'conventional-changelog' ;
@@ -48,20 +48,19 @@ class ConventionalChangelog extends Plugin {
48
48
async function getWhatBump ( ) {
49
49
if ( options . whatBump === false ) {
50
50
return ( ) => ( { releaseType : null } ) ;
51
- } else {
52
- const bumperPreset = await bumper . preset ;
51
+ }
52
+ const bumperPreset = await bumper . preset ;
53
53
54
- if ( bumperPreset === null ) return ( ) => ( { releaseType : null } ) ;
54
+ if ( bumperPreset === null ) return ( ) => ( { releaseType : null } ) ;
55
55
56
- return bumperPreset . whatBump || bumperPreset . recommendedBumpOpts . whatBump ;
57
- }
56
+ return bumperPreset . whatBump || bumperPreset . recommendedBumpOpts . whatBump ;
58
57
}
59
58
60
- const result = await bumper . bump ( await getWhatBump ( ) ) ;
59
+ const recommendation = await bumper . bump ( await getWhatBump ( ) ) ;
61
60
62
- this . debug ( { result } ) ;
61
+ this . debug ( { result : recommendation } ) ;
63
62
64
- let { releaseType } = result ;
63
+ let { releaseType } = recommendation ;
65
64
66
65
if ( increment ) {
67
66
this . log . warn ( `The recommended bump is "${ releaseType } ", but is overridden with "${ increment } ".` ) ;
@@ -70,7 +69,9 @@ class ConventionalChangelog extends Plugin {
70
69
71
70
if ( increment && semver . valid ( increment ) ) {
72
71
return increment ;
73
- } else if ( isPreRelease ) {
72
+ }
73
+
74
+ if ( isPreRelease ) {
74
75
if ( releaseType && ( options . strictSemVer || ! semver . prerelease ( latestVersion ) ) ) {
75
76
return semver . inc ( latestVersion , `pre${ releaseType } ` , preReleaseId ) ;
76
77
}
@@ -91,9 +92,9 @@ class ConventionalChangelog extends Plugin {
91
92
92
93
if (
93
94
lastStableTag &&
94
- ( releaseTypeToLastNonPrerelease == 'major' ||
95
- releaseTypeToLastNonPrerelease == 'minor' ||
96
- releaseTypeToLastNonPrerelease == 'patch' )
95
+ ( releaseTypeToLastNonPrerelease === 'major' ||
96
+ releaseTypeToLastNonPrerelease === 'minor' ||
97
+ releaseTypeToLastNonPrerelease === 'patch' )
97
98
) {
98
99
if (
99
100
semver [ releaseTypeToLastNonPrerelease ] ( lastStableTag ) ==
@@ -104,11 +105,13 @@ class ConventionalChangelog extends Plugin {
104
105
}
105
106
106
107
return semver . inc ( latestVersion , 'prerelease' , preReleaseId ) ;
107
- } else if ( releaseType ) {
108
+ }
109
+
110
+ if ( releaseType ) {
108
111
return semver . inc ( latestVersion , releaseType , preReleaseId ) ;
109
- } else {
110
- return null ;
111
112
}
113
+
114
+ return null ;
112
115
} catch ( err ) {
113
116
this . debug ( { err } ) ;
114
117
throw err ;
0 commit comments