From cff11656dbfc4d741afd90a7cf6295feb5dab2e7 Mon Sep 17 00:00:00 2001 From: Steven Bouwkamp Date: Mon, 23 Dec 2024 17:31:22 -0500 Subject: [PATCH] Attempt to fix issue installing latest always --- packages/dd-trace/test/setup/mocha.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/dd-trace/test/setup/mocha.js b/packages/dd-trace/test/setup/mocha.js index c16213b6878..afcb60534af 100644 --- a/packages/dd-trace/test/setup/mocha.js +++ b/packages/dd-trace/test/setup/mocha.js @@ -198,9 +198,18 @@ function withVersions (plugin, modules, range, cb) { testVersions.set(min, { range: version, test: min }) } - // TODO may run into issues with the latest version being greater than supported Node - if (latestVersion) { - testVersions.set(latestVersion, { range: version, test: latestVersion }) + // 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 }) + } else if (latestVersion) { + const range = process.env.PACKAGE_VERSION_RANGE + const testVersion = semver.satisfies(latestVersion, range) + ? latestVersion + : semver.maxSatisfying([version, latestVersion], range) + if (testVersion) { + testVersions.set(testVersion, { range: version, test: testVersion }) + } } else { const max = require(`../../../../versions/${moduleName}@${version}`).version() testVersions.set(max, { range: version, test: version })