@@ -36,7 +36,12 @@ export async function getNewVersion(operation: Operation): Promise<Operation> {
36
36
*/
37
37
function getNextVersion ( oldVersion : string , bump : BumpRelease ) : string {
38
38
const oldSemVer = new SemVer ( oldVersion )
39
- const newSemVer = oldSemVer . inc ( bump . type as any , bump . preid )
39
+
40
+ const type = bump . type === 'next'
41
+ ? oldSemVer . prerelease . length ? 'prerelease' : 'patch'
42
+ : bump . type
43
+
44
+ const newSemVer = oldSemVer . inc ( type , bump . preid )
40
45
41
46
if (
42
47
isPrerelease ( bump . type )
@@ -58,19 +63,15 @@ function getNextVersion(oldVersion: string, bump: BumpRelease): string {
58
63
/**
59
64
* Returns the next version number for all release types.
60
65
*/
61
- function getNextVersions ( oldVersion : string , preid : string ) : Record < ReleaseType | 'next' , string > {
66
+ function getNextVersions ( oldVersion : string , preid : string ) : Record < ReleaseType , string > {
62
67
const next : Record < string , string > = { }
63
68
64
69
const parse = semver . parse ( oldVersion )
65
70
if ( typeof parse ?. prerelease [ 0 ] === 'string' )
66
71
preid = parse ?. prerelease [ 0 ] || 'preid'
67
72
68
73
for ( const type of releaseTypes )
69
- next [ type ] = semver . inc ( oldVersion , type , preid ) !
70
-
71
- next . next = parse ?. prerelease ?. length
72
- ? semver . inc ( oldVersion , 'prerelease' , preid ) !
73
- : semver . inc ( oldVersion , 'patch' ) !
74
+ next [ type ] = getNextVersion ( oldVersion , { type, preid } )
74
75
75
76
return next
76
77
}
@@ -121,7 +122,7 @@ async function promptForNewVersion(operation: Operation): Promise<Operation> {
121
122
} ,
122
123
} ,
123
124
] ) as {
124
- release : ReleaseType | 'next' | ' none' | 'custom' | 'config'
125
+ release : ReleaseType | 'none' | 'custom' | 'config'
125
126
custom ?: string
126
127
}
127
128
0 commit comments