mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2026-04-18 20:59:51 +00:00
Add "pre-release" mode (MINOR)
This commit is contained in:
parent
8b3b8f89c6
commit
ddf8faf6a4
11 changed files with 93 additions and 5 deletions
|
|
@ -17,6 +17,7 @@ class DefaultVersionClassifier {
|
|||
const searchBody = config.searchCommitBody;
|
||||
this.majorPattern = this.parsePattern(config.majorPattern, config.majorFlags, searchBody);
|
||||
this.minorPattern = this.parsePattern(config.minorPattern, config.minorFlags, searchBody);
|
||||
this.enablePrereleaseMode = config.enablePrereleaseMode;
|
||||
}
|
||||
parsePattern(pattern, flags, searchBody) {
|
||||
if (pattern.startsWith('/') && pattern.endsWith('/')) {
|
||||
|
|
@ -33,6 +34,19 @@ class DefaultVersionClassifier {
|
|||
}
|
||||
}
|
||||
getNextVersion(current, type) {
|
||||
if (this.enablePrereleaseMode && current.major === 0) {
|
||||
switch (type) {
|
||||
case VersionType_1.VersionType.Major:
|
||||
return { major: current.major, minor: current.minor + 1, patch: 0 };
|
||||
case VersionType_1.VersionType.Minor:
|
||||
case VersionType_1.VersionType.Patch:
|
||||
return { major: current.major, minor: current.minor, patch: current.patch + 1 };
|
||||
case VersionType_1.VersionType.None:
|
||||
return { major: current.major, minor: current.minor, patch: current.patch };
|
||||
default:
|
||||
throw new Error(`Unknown change type: ${type}`);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case VersionType_1.VersionType.Major:
|
||||
return { major: current.major + 1, minor: 0, patch: 0 };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue