Skip to content

Commit

Permalink
✨ Add resetting version only if prefix changed
Browse files Browse the repository at this point in the history
  • Loading branch information
priestine committed Jul 3, 2020
1 parent 46b3e3c commit 5c7ce0f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pure/make-new-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import type { BumpKey } from '../types/common-types'
import { Either } from '../utils/either'
import { extractVersionTuple } from '../utils/helpers'

type Ctx = Pick<IAppCtx, 'latestVersion' | 'public' | 'prefixReset' | BumpKey>
type Ctx = Pick<IAppCtx, 'latestVersion' | 'public' | 'prefixReset' | 'prefix' | BumpKey>

export const makeNewVersion = ({
latestVersion,
public: isPublic,
prefixReset,
prefix,
bumpPatch,
bumpMinor,
bumpMajor,
Expand All @@ -25,7 +26,7 @@ export const makeNewVersion = ({
? [major, bumpMajor ? minor : minor + 1, 0]
: [major, minor, patch],
)
.map((result) => (prefixReset ? [1, 0, 0] : result))
.map((result) => (prefixReset && !latestVersion.startsWith(prefix) ? [1, 0, 0] : result))
.map((tuple) => tuple.join('.'))
.fold(
() => `${isPublic ? '1.0' : '0.1'}.0`,
Expand Down

0 comments on commit 5c7ce0f

Please sign in to comment.