Skip to content

Commit

Permalink
chore: lint and improve nested class
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi committed Dec 11, 2024
1 parent 832baaa commit d0163e7
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/release/semver-versioning-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const inc = (version, release, _preid) => {
}
const isFreshMajor = parsed.minor === 0 && parsed.patch === 0
const isFreshMinor = parsed.patch === 0
const shouldPrerelease = (release === 'premajor' && isFreshMajor) || (release === 'preminor' && isFreshMinor) || release === 'prepatch'
const shouldPrerelease =
(release === 'premajor' && isFreshMajor) || (release === 'preminor' && isFreshMinor) || release === 'prepatch'
if (shouldPrerelease) {
return semver.inc(version, 'prerelease', preid)
}
Expand All @@ -31,19 +32,25 @@ const parseCommits = commits => {
return release
}

class SemverVersioningStrategyNested {
constructor(options, version, commits) {
this.options = options
this.commits = commits
this.version = version
}

bump() {
return new SemverVersioningStrategy(this.options).bump(this.version, this.commits)
}
}

class SemverVersioningStrategy {
constructor(options) {
this.options = options
}

determineReleaseType(_version, _commits) {
const options = this.options
class Shell {
bump() {
return new SemverVersioningStrategy(options).bump(_version, _commits)
}
}
return new Shell()
determineReleaseType(version, commits) {
return new SemverVersioningStrategyNested(this.options, version, commits)
}

bump(currentVersion, commits) {
Expand Down

0 comments on commit d0163e7

Please sign in to comment.