diff --git a/lib/datasource/npm.js b/lib/datasource/npm.js index 70bb2a9a9780ee9c97649fb954dca2a3adb4283b..20077dbfdcb1d50d9b062a1d7e25a7956a71ae6f 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 2091aa0f5ceb0e69179fdc52f5a82d2b70bb3656..44465b79e0ecfdf8104fb65a6741695f32acc939 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(); });