@@ -17,6 +17,19 @@ const getNextVersion = (pkg) => {
17
17
: lastVersion || "1.0.0" ;
18
18
} ;
19
19
20
+ /**
21
+ * Resolve next package version on prereleases.
22
+ *
23
+ * @param {Package } pkg Package object.
24
+ * @returns {string|undefined } Next pkg version.
25
+ * @internal
26
+ */
27
+ const getNextPreVersion = ( pkg ) => {
28
+ const lastVersion = pkg . _lastRelease && pkg . _lastRelease . version ;
29
+
30
+ return lastVersion ? semver . inc ( lastVersion , "prerelease" , pkg . _preRelease ) : `1.0.0-${ pkg . _preRelease } .1` ;
31
+ } ;
32
+
20
33
/**
21
34
* Resolve package release type taking into account the cascading dependency update.
22
35
*
@@ -90,7 +103,12 @@ const getDependentRelease = (pkg, bumpStrategy, releaseStrategy, ignore) => {
90
103
// 1. Any local dep package itself has changed
91
104
// 2. Any local dep package has local deps that have changed.
92
105
const nextType = resolveReleaseType ( p , bumpStrategy , releaseStrategy , [ ...ignore , ...localDeps ] ) ;
93
- const nextVersion = getNextVersion ( p ) ;
106
+
107
+ // Set the nextVersion fallback to the last local dependency package last version
108
+ let nextVersion = p . _lastRelease && p . _lastRelease . version ;
109
+
110
+ // Update the nextVersion only if there is a next type to be bumped
111
+ if ( nextType ) nextVersion = p . _preRelease ? getNextPreVersion ( p ) : getNextVersion ( p ) ;
94
112
const lastVersion = pkg . _lastRelease && pkg . _lastRelease . version ;
95
113
96
114
// 3. And this change should correspond to manifest updating rule.
@@ -169,6 +187,7 @@ const updateManifestDeps = (pkg) => {
169
187
170
188
module . exports = {
171
189
getNextVersion,
190
+ getNextPreVersion,
172
191
updateManifestDeps,
173
192
resolveReleaseType,
174
193
resolveNextVersion,
0 commit comments