From 2b2fbe97f196e6c50ea24d6bab7b3b07dfd54b0e Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Fri, 11 May 2018 20:10:07 +0200 Subject: [PATCH] fix(npm): massage _auth to _authToken --- lib/datasource/npm.js | 8 ++++++++ test/manager/npm/registry.spec.js | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/datasource/npm.js b/lib/datasource/npm.js index 70bb2a9a97..20077dbfdc 100644 --- a/lib/datasource/npm.js +++ b/lib/datasource/npm.js @@ -51,6 +51,14 @@ function setNpmrc(input, exposeEnv = false) { const token = npmrc[tokenKey]; logger.debug(`Setting authToken to ${maskToken(token)}`); } + // massage _auth to _authToken + for (const [key, val] of Object.entries(npmrc)) { + if (key.endsWith('_auth')) { + logger.debug('Massaging _auth to _authToken'); + npmrc[key + 'Token'] = val; + delete npmrc[key]; + } + } if (!exposeEnv) { return; } diff --git a/test/manager/npm/registry.spec.js b/test/manager/npm/registry.spec.js index 2091aa0f5c..44465b79e0 100644 --- a/test/manager/npm/registry.spec.js +++ b/test/manager/npm/registry.spec.js @@ -200,7 +200,9 @@ describe('api/npm', () => { nock('https://npm.mycustomregistry.com') .get('/foobar') .reply(200, npmResponse); - npm.setNpmrc('registry=https://npm.mycustomregistry.com/'); + npm.setNpmrc( + 'registry=https://npm.mycustomregistry.com/\n//npm.mycustomregistry.com/:_auth = abcdef' + ); const res = await npm.getDependency('foobar'); expect(res).toMatchSnapshot(); }); -- GitLab