Skip to content

Commit

Permalink
Validate semver ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
bouwkast committed Dec 30, 2024
1 parent cff1165 commit e8869a6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/dd-trace/test/setup/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,13 @@ function withVersions (plugin, modules, range, cb) {

// TODO may run into issues with the latest version being greater than supported Node?
if (latestVersion && !process.env.PACKAGE_VERSION_RANGE) {
const testVersion = semver.lte(version, latestVersion) ? version : latestVersion
testVersions.set(testVersion, { range: version, test: testVersion })
if (semver.valid(version)) {
const testVersion = semver.lte(version, latestVersion) ? version : latestVersion
testVersions.set(testVersion, { range: version, test: testVersion })
} else if (semver.validRange(version)) {
const testVersion = semver.maxSatisfying([version, latestVersion], version)
testVersions.set(testVersion, { range: version, test: testVersion })
}
} else if (latestVersion) {
const range = process.env.PACKAGE_VERSION_RANGE
const testVersion = semver.satisfies(latestVersion, range)
Expand Down

0 comments on commit e8869a6

Please sign in to comment.