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-25 19:00:24 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-03-26 00:41:42 +0300
commit1415b4bdeeaabb6e0ba12b6b1b0cc56502bd64ab (patch)
tree009e2f4027a8fe921fcdf585c4e41315962425ef /test
parent97b41528739460b2e9e72e09000aded412418cb2 (diff)
fix(config): properly translate user-agent
This config item is a bit of a unique one, as it can be set as a template, but then gets translated and also populated to process.env.npm_config_user_agent. This adds that logic back in during the flattening. PR-URL: https://github.com/npm/cli/pull/2964 Credit: @wraithgar Close: #2964 Reviewed-by: @nlf
Diffstat (limited to 'test')
-rw-r--r--test/lib/utils/config/definitions.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js
index b6e1d1d01..49e51ace1 100644
--- a/test/lib/utils/config/definitions.js
+++ b/test/lib/utils/config/definitions.js
@@ -733,10 +733,16 @@ t.test('user-agent', t => {
`${process.platform} ${process.arch}`
definitions['user-agent'].flatten('user-agent', obj, flat)
t.equal(flat.userAgent, expectNoCI)
+ t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
+ t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
+
obj['ci-name'] = 'foo'
+ obj['user-agent'] = definitions['user-agent'].default
const expectCI = `${expectNoCI} ci/foo`
definitions['user-agent'].flatten('user-agent', obj, flat)
t.equal(flat.userAgent, expectCI)
+ t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
+ t.equal(obj['user-agent'], flat.userAgent, 'config user-agent template is translated')
t.end()
})