Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-03-24 17:40:21 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-03-24 17:52:54 +0300
commitdce4960ef6d52af128affe7755b2ca72de913b6c (patch)
treed7eab73ed9420bce24cd75be6ded97f9c72ac239 /test
parent543b0e39bcb94fc408804b01ca9c0d7b960b2681 (diff)
fix(config): flatten savePrefix properly
It needs to take save-exact into consideration Closes: https://github.com/npm/cli/issues/2932 PR-URL: https://github.com/npm/cli/pull/2937 Credit: @wraithgar Close: #2937 Reviewed-by: @ruyadorno
Diffstat (limited to 'test')
-rw-r--r--test/lib/utils/config/definitions.js15
-rw-r--r--test/lib/utils/config/flatten.js6
2 files changed, 21 insertions, 0 deletions
diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js
index 3169feefb..830468c43 100644
--- a/test/lib/utils/config/definitions.js
+++ b/test/lib/utils/config/definitions.js
@@ -695,3 +695,18 @@ t.test('user-agent', t => {
t.equal(flat.userAgent, expectCI)
t.end()
})
+
+t.test('save-prefix', t => {
+ const obj = {
+ 'save-exact': true,
+ 'save-prefix': '~1.2.3',
+ }
+ const flat = {}
+ definitions['save-prefix']
+ .flatten('save-prefix', { ...obj, 'save-exact': true }, flat)
+ t.strictSame(flat, { savePrefix: '' })
+ definitions['save-prefix']
+ .flatten('save-prefix', { ...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 9fac0820c..6fc91b484 100644
--- a/test/lib/utils/config/flatten.js
+++ b/test/lib/utils/config/flatten.js
@@ -6,6 +6,8 @@ delete process.env.NODE
process.execPath = '/path/to/node'
const obj = {
+ 'save-exact': true,
+ 'save-prefix': 'ignored',
'save-dev': true,
'@foobar:registry': 'https://foo.bar.com/',
'//foo.bar.com:_authToken': 'foobarbazquuxasdf',
@@ -15,6 +17,8 @@ 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',
npmBin: '/path/to/npm',
@@ -26,6 +30,8 @@ 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',
npmBin: '/path/to/npm',