diff --git a/__tests__/authutil.test.ts b/__tests__/authutil.test.ts index a57a317..1ec4e1e 100644 --- a/__tests__/authutil.test.ts +++ b/__tests__/authutil.test.ts @@ -123,4 +123,13 @@ describe('authutil tests', () => { expect(rc['registry']).toBe('https://registry.npmjs.org/'); expect(rc['always-auth']).toBe('true'); }); + it('It is already set the NODE_AUTH_TOKEN export it ', async () => { + process.env.NODE_AUTH_TOKEN = 'foobar'; + await auth.configAuthentication('npm.pkg.github.com', 'false'); + expect(fs.statSync(rcFile)).toBeDefined(); + let rc = readRcFile(rcFile); + expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/'); + expect(rc['always-auth']).toBe('false'); + expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar'); + }); }); diff --git a/dist/index.js b/dist/index.js index c959e0a..0276299 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4803,8 +4803,8 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) { newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`; fs.writeFileSync(fileLocation, newContents); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); - // Export empty node_auth_token so npm doesn't complain about not being able to find it - core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); + // Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it + core.exportVariable('NODE_AUTH_TOKEN', process.env.NODE_AUTH_TOKEN || 'XXXXX-XXXXX-XXXXX-XXXXX'); } //# sourceMappingURL=authutil.js.map diff --git a/src/authutil.ts b/src/authutil.ts index 07e0b24..aaebdfd 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -53,6 +53,9 @@ function writeRegistryToFile( newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`; fs.writeFileSync(fileLocation, newContents); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); - // Export empty node_auth_token so npm doesn't complain about not being able to find it - core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); + // Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it + core.exportVariable( + 'NODE_AUTH_TOKEN', + process.env.NODE_AUTH_TOKEN || 'XXXXX-XXXXX-XXXXX-XXXXX' + ); }