From 615b581f4dbcd322929805164d7a16961a5a07db Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 9 Apr 2022 23:03:11 -0400 Subject: [PATCH 1/2] test(inc): ensure SemVer instanced passed as input are not modified --- test/functions/inc.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/functions/inc.js b/test/functions/inc.js index c91f6ebc..909debdf 100644 --- a/test/functions/inc.js +++ b/test/functions/inc.js @@ -10,10 +10,20 @@ test('increment versions test', (t) => { t.equal(found, wanted, `${cmd} === ${wanted}`) const parsed = parse(pre, options) + const parsedAsInput = parse(pre, options) if (wanted) { parsed.inc(what, id) t.equal(parsed.version, wanted, `${cmd} object version updated`) t.equal(parsed.raw, wanted, `${cmd} object raw field updated`) + + const preIncObject = JSON.stringify(parsedAsInput) + inc(parsedAsInput, what, options, id) + const postIncObject = JSON.stringify(parsedAsInput) + t.equal( + postIncObject, + preIncObject, + `${cmd} didn't modify its input` + ) } else if (parsed) { t.throws(() => { parsed.inc(what, id) From fd67a715bfeeb68ed49f3394826cd44ef9d5657f Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Thu, 27 Jan 2022 21:51:56 -0500 Subject: [PATCH 2/2] fix(inc): ensure SemVer instanced passed as input are not modified --- functions/inc.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/inc.js b/functions/inc.js index aa4d83ab..62d1da2c 100644 --- a/functions/inc.js +++ b/functions/inc.js @@ -7,7 +7,10 @@ const inc = (version, release, options, identifier) => { } try { - return new SemVer(version, options).inc(release, identifier).version + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier).version } catch (er) { return null }