Skip to content

Commit

Permalink
Merge branch 'main' into v-malob/update-readme-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Lobanov committed Dec 16, 2020
2 parents 2bfa943 + d06286d commit 1d846de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 9 additions & 0 deletions __tests__/authutil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions src/authutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}

0 comments on commit 1d846de

Please sign in to comment.