From 59271936d90fbd6956a41967119f578c0ba63db9 Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 25 Mar 2021 09:46:01 -0700 Subject: fix(config): tie save-exact/save-prefix together Each affects the other PR-URL: https://github.com/npm/cli/pull/2965 Credit: @wraithgar Close: #2965 Reviewed-by: @nlf --- test/lib/utils/config/definitions.js | 15 +++++++++++++++ test/lib/utils/config/flatten.js | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js index 49e51ace1..0b80b34d5 100644 --- a/test/lib/utils/config/definitions.js +++ b/test/lib/utils/config/definitions.js @@ -760,3 +760,18 @@ t.test('save-prefix', t => { t.strictSame(flat, { savePrefix: '~1.2.3' }) t.end() }) + +t.test('save-exact', t => { + const obj = { + 'save-exact': true, + 'save-prefix': '~1.2.3', + } + const flat = {} + definitions['save-exact'] + .flatten('save-exact', { ...obj, 'save-exact': true }, flat) + t.strictSame(flat, { savePrefix: '' }) + definitions['save-exact'] + .flatten('save-exact', { ...obj, 'save-exact': false }, flat) + t.strictSame(flat, { savePrefix: '~1.2.3' }) + t.end() +}) diff --git a/test/lib/utils/config/flatten.js b/test/lib/utils/config/flatten.js index 6fc91b484..7e1356392 100644 --- a/test/lib/utils/config/flatten.js +++ b/test/lib/utils/config/flatten.js @@ -17,7 +17,6 @@ const obj = { const flat = flatten(obj) t.strictSame(flat, { saveType: 'dev', - saveExact: true, savePrefix: '', '@foobar:registry': 'https://foo.bar.com/', '//foo.bar.com:_authToken': 'foobarbazquuxasdf', @@ -30,7 +29,6 @@ t.strictSame(flat, { process.env.NODE = '/usr/local/bin/node.exe' flatten({ 'save-dev': false }, flat) t.strictSame(flat, { - saveExact: true, savePrefix: '', '@foobar:registry': 'https://foo.bar.com/', '//foo.bar.com:_authToken': 'foobarbazquuxasdf', -- cgit v1.2.3