From 28f3e65671164aa6d9a0c2fc7409c2c3e00bf40f Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Mon, 22 Feb 2021 14:33:26 -0700 Subject: [PATCH] Add support for simple versions without "v" (#830) --- lib/version-util.js | 2 +- test/versionmanager.test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/version-util.js b/lib/version-util.js index 0a829c6b..c5670aff 100644 --- a/lib/version-util.js +++ b/lib/version-util.js @@ -232,7 +232,7 @@ function isPre(version) { } /** Checks if a string is a simple version in the format "v1". */ -const isSimpleVersion = s => /^[vV]\d+$/.test(s) +const isSimpleVersion = s => /^[vV]?\d+$/.test(s) /** * Returns 'v' if the string starts with a v, otherwise returns empty string. diff --git a/test/versionmanager.test.js b/test/versionmanager.test.js index 0e7cc6fe..6a20ae9e 100644 --- a/test/versionmanager.test.js +++ b/test/versionmanager.test.js @@ -283,6 +283,7 @@ describe('versionmanager', () => { describe('upgradeDependencies', () => { it('upgrade simple, non-semver versions', () => { + vm.upgradeDependencies({ foo: '1' }, { foo: '2' }).should.eql({ foo: '2' }) vm.upgradeDependencies({ mongodb: '0.5' }, { mongodb: '1.4.30' }).should.eql({ mongodb: '1.4' }) vm.upgradeDependencies({ 'ncu-test-simple-tag': 'v1' }, { 'ncu-test-simple-tag': 'v3' }).should.eql({ 'ncu-test-simple-tag': 'v3' }) })