Socket
Socket
Sign inDemoInstall

semver

Package Overview
Dependencies
1
Maintainers
6
Versions
107
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.4.0 to 7.5.0

8

bin/semver.js

@@ -79,2 +79,5 @@ #!/usr/bin/env node

identifierBase = argv.shift()
if (identifierBase === 'false') {
identifierBase = false
}
break

@@ -182,2 +185,7 @@ case '-c': case '--coerce':

-n <base>
Base number to be used for the prerelease identifier.
Can be either 0 or 1, or false to omit the number altogether.
Defaults to 0.
Program exits successfully if any valid version satisfies

@@ -184,0 +192,0 @@ all supplied ranges, and prints all satisfying versions.

28

classes/semver.js

@@ -19,3 +19,3 @@ const debug = require('../internal/debug')

} else if (typeof version !== 'string') {
throw new TypeError(`Invalid Version: ${version}`)
throw new TypeError(`Invalid Version: ${require('util').inspect(version)}`)
}

@@ -250,5 +250,11 @@

// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
case 'pre':
case 'pre': {
const base = Number(identifierBase) ? 1 : 0
if (!identifier && identifierBase === false) {
throw new Error('invalid increment argument: identifier is empty')
}
if (this.prerelease.length === 0) {
this.prerelease = [0]
this.prerelease = [base]
} else {

@@ -264,19 +270,25 @@ let i = this.prerelease.length

// didn't increment anything
this.prerelease.push(0)
if (identifier === this.prerelease.join('.') && identifierBase === false) {
throw new Error('invalid increment argument: identifier already exists')
}
this.prerelease.push(base)
}
}
if (identifier) {
const base = Number(identifierBase) ? 1 : 0
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
let prerelease = [identifier, base]
if (identifierBase === false) {
prerelease = [identifier]
}
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
if (isNaN(this.prerelease[1])) {
this.prerelease = [identifier, base]
this.prerelease = prerelease
}
} else {
this.prerelease = [identifier, base]
this.prerelease = prerelease
}
}
break
}
default:

@@ -283,0 +295,0 @@ throw new Error(`invalid increment argument: ${release}`)

@@ -1,39 +0,54 @@

const parse = require('./parse')
const eq = require('./eq')
const parse = require('./parse.js')
const diff = (version1, version2) => {
const v1 = parse(version1)
const v2 = parse(version2)
if (eq(v1, v2)) {
const v1 = parse(version1, null, true)
const v2 = parse(version2, null, true)
const comparison = v1.compare(v2)
if (comparison === 0) {
return null
} else {
const hasPre = v1.prerelease.length || v2.prerelease.length
const prefix = hasPre ? 'pre' : ''
const defaultResult = hasPre ? 'prerelease' : ''
}
if (v1.major !== v2.major) {
return prefix + 'major'
}
if (v1.minor !== v2.minor) {
return prefix + 'minor'
}
const v1Higher = comparison > 0
const highVersion = v1Higher ? v1 : v2
const lowVersion = v1Higher ? v2 : v1
const highHasPre = !!highVersion.prerelease.length
if (v1.patch !== v2.patch) {
return prefix + 'patch'
}
// add the `pre` prefix if we are going to a prerelease version
const prefix = highHasPre ? 'pre' : ''
if (!v1.prerelease.length || !v2.prerelease.length) {
if (v1.patch) {
return 'patch'
}
if (v1.minor) {
return 'minor'
}
if (v1.major) {
return 'major'
}
}
return defaultResult // may be undefined
if (v1.major !== v2.major) {
return prefix + 'major'
}
if (v1.minor !== v2.minor) {
return prefix + 'minor'
}
if (v1.patch !== v2.patch) {
return prefix + 'patch'
}
// at this point we know stable versions match but overall versions are not equal,
// so either they are both prereleases, or the lower version is a prerelease
if (highHasPre) {
// high and low are preleases
return 'prerelease'
}
if (lowVersion.patch) {
// anything higher than a patch bump would result in the wrong version
return 'patch'
}
if (lowVersion.minor) {
// anything higher than a minor bump would result in the wrong version
return 'minor'
}
// bumping major/minor/patch all have same result
return 'major'
}
module.exports = diff

@@ -1,20 +0,13 @@

const { MAX_LENGTH } = require('../internal/constants')
const SemVer = require('../classes/semver')
const parse = (version, options) => {
const parse = (version, options, throwErrors = false) => {
if (version instanceof SemVer) {
return version
}
if (typeof version !== 'string') {
return null
}
if (version.length > MAX_LENGTH) {
return null
}
try {
return new SemVer(version, options)
} catch (er) {
return null
if (!throwErrors) {
return null
}
throw er
}

@@ -21,0 +14,0 @@ }

{
"name": "semver",
"version": "7.4.0",
"version": "7.5.0",
"description": "The semantic version parser used by npm.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -242,2 +242,3 @@ semver(1) -- The semantic versioner for npm

that will let you let your prerelease number as zero-based or one-based.
Set to `false` to omit the prerelease number altogether.
If you do not specify this parameter, it will default to zero-based.

@@ -250,2 +251,7 @@

```javascript
semver.inc('1.2.3', 'prerelease', 'beta', false)
// '1.2.4-beta'
```
command-line example:

@@ -258,2 +264,7 @@

```bash
$ semver 1.2.3 -i prerelease --preid beta -n false
1.2.4-beta
```
### Advanced Range Syntax

@@ -260,0 +271,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc