Skip to content

Commit 659d439

Browse files
cq-botgithub-actions[bot]
authored andcommitted
chore: Prepare dist
1 parent e112c99 commit 659d439

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

dist/index.js

+29-18
Original file line numberDiff line numberDiff line change
@@ -4454,7 +4454,7 @@ const testSet = (set, version, options) => {
44544454

44554455
const debug = __nccwpck_require__(1159)
44564456
const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5101)
4457-
const { safeRe: re, t } = __nccwpck_require__(5471)
4457+
const { safeRe: re, safeSrc: src, t } = __nccwpck_require__(5471)
44584458

44594459
const parseOptions = __nccwpck_require__(356)
44604460
const { compareIdentifiers } = __nccwpck_require__(3348)
@@ -4464,7 +4464,7 @@ class SemVer {
44644464

44654465
if (version instanceof SemVer) {
44664466
if (version.loose === !!options.loose &&
4467-
version.includePrerelease === !!options.includePrerelease) {
4467+
version.includePrerelease === !!options.includePrerelease) {
44684468
return version
44694469
} else {
44704470
version = version.version
@@ -4630,6 +4630,20 @@ class SemVer {
46304630
// preminor will bump the version up to the next minor release, and immediately
46314631
// down to pre-release. premajor and prepatch work the same way.
46324632
inc (release, identifier, identifierBase) {
4633+
if (release.startsWith('pre')) {
4634+
if (!identifier && identifierBase === false) {
4635+
throw new Error('invalid increment argument: identifier is empty')
4636+
}
4637+
// Avoid an invalid semver results
4638+
if (identifier) {
4639+
const r = new RegExp(`^${this.options.loose ? src[t.PRERELEASELOOSE] : src[t.PRERELEASE]}$`)
4640+
const match = `-${identifier}`.match(r)
4641+
if (!match || match[1] !== identifier) {
4642+
throw new Error(`invalid identifier: ${identifier}`)
4643+
}
4644+
}
4645+
}
4646+
46334647
switch (release) {
46344648
case 'premajor':
46354649
this.prerelease.length = 0
@@ -4660,6 +4674,12 @@ class SemVer {
46604674
}
46614675
this.inc('pre', identifier, identifierBase)
46624676
break
4677+
case 'release':
4678+
if (this.prerelease.length === 0) {
4679+
throw new Error(`version ${this.raw} is not a prerelease`)
4680+
}
4681+
this.prerelease.length = 0
4682+
break
46634683

46644684
case 'major':
46654685
// If this is a pre-major version, bump up to the same major version.
@@ -4703,10 +4723,6 @@ class SemVer {
47034723
case 'pre': {
47044724
const base = Number(identifierBase) ? 1 : 0
47054725

4706-
if (!identifier && identifierBase === false) {
4707-
throw new Error('invalid increment argument: identifier is empty')
4708-
}
4709-
47104726
if (this.prerelease.length === 0) {
47114727
this.prerelease = [base]
47124728
} else {
@@ -4965,20 +4981,13 @@ const diff = (version1, version2) => {
49654981
return 'major'
49664982
}
49674983

4968-
// Otherwise it can be determined by checking the high version
4969-
4970-
if (highVersion.patch) {
4971-
// anything higher than a patch bump would result in the wrong version
4984+
// If the main part has no difference
4985+
if (lowVersion.compareMain(highVersion) === 0) {
4986+
if (lowVersion.minor && !lowVersion.patch) {
4987+
return 'minor'
4988+
}
49724989
return 'patch'
49734990
}
4974-
4975-
if (highVersion.minor) {
4976-
// anything higher than a minor bump would result in the wrong version
4977-
return 'minor'
4978-
}
4979-
4980-
// bumping major/minor/patch all have same result
4981-
return 'major'
49824991
}
49834992

49844993
// add the `pre` prefix if we are going to a prerelease version
@@ -5485,6 +5494,7 @@ exports = module.exports = {}
54855494
const re = exports.re = []
54865495
const safeRe = exports.safeRe = []
54875496
const src = exports.src = []
5497+
const safeSrc = exports.safeSrc = []
54885498
const t = exports.t = {}
54895499
let R = 0
54905500

@@ -5517,6 +5527,7 @@ const createToken = (name, value, isGlobal) => {
55175527
debug(name, index, value)
55185528
t[name] = index
55195529
src[index] = value
5530+
safeSrc[index] = safe
55205531
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
55215532
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
55225533
}

0 commit comments

Comments
 (0)