From 9a306048a9f59644974765acf4abf512df5cde2f Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Tue, 20 Apr 2021 06:56:16 +0200 Subject: [PATCH] fix: rangeStrategy=replace with lockedVersion (#9634) --- lib/workers/repository/process/lookup/index.spec.ts | 9 +++++++++ lib/workers/repository/process/lookup/index.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index 8aecd513dd35ef..93413f8a63acdb 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -347,6 +347,15 @@ describe(getName(__filename), () => { nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0); }); + it('ignores minor ranged versions when locked', async () => { + config.rangeStrategy = 'replace'; + config.currentValue = '^1.0.0'; + config.lockedVersion = '1.1.0'; + config.depName = 'q'; + config.datasource = datasourceNpmId; + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); + expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0); + }); it('upgrades tilde ranges', async () => { config.rangeStrategy = 'pin'; config.currentValue = '~1.3.0'; diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index 84b21acdc1e098..07251b2d7e4a43 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -138,7 +138,6 @@ export async function lookupUpdates( .filter((release) => !release.isDeprecated) .map((release) => release.version); const currentVersion = - lockedVersion || getCurrentVersion( config, versioning, @@ -290,6 +289,7 @@ export async function lookupUpdates( // Record if the dep is fixed to a version if (lockedVersion) { + res.currentVersion = lockedVersion; res.fixedVersion = lockedVersion; } else if (currentValue && versioning.isSingleVersion(currentValue)) { res.fixedVersion = currentValue.replace(/^=+/, '');