Skip to content

Commit

Permalink
fix(npm): replace all instances of $NPM_TOKEN in npmrc (#6431)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jun 4, 2020
1 parent a23562a commit 08de7af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/config/decrypt.spec.ts
Expand Up @@ -36,7 +36,8 @@ describe('config/decrypt', () => {
});
it('replaces npm token placeholder in npmrc', () => {
config.privateKey = privateKey;
config.npmrc = '//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n'; // eslint-disable-line no-template-curly-in-string
config.npmrc =
'//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n'; // eslint-disable-line no-template-curly-in-string
config.encrypted = {
npmToken:
'FLA9YHIzpE7YetAg/P0X46npGRCMqn7hgyzwX5ZQ9wYgu9BRRbTiBVsUIFTyM5BuP1Q22slT2GkWvFvum7GU236Y6QiT7Nr8SLvtsJn2XUuq8H7REFKzdy3+wqyyWbCErYTFyY1dcPM7Ht+CaGDWdd8u/FsoX7AdMRs/X1jNUo6iSmlUiyGlYDKF+QMnCJom1VPVgZXWsGKdjI2MLny991QMaiv0VajmFIh4ENv4CtXOl/1twvIl/6XTXAaqpJJKDTPZEuydi+PHDZmal2RAOfrkH4m0UURa7SlfpUlIg+EaqbNGp85hCYXLwRcEET1OnYr3rH1oYkcYJ40any1tvQ==',
Expand All @@ -45,7 +46,7 @@ describe('config/decrypt', () => {
expect(res.encrypted).not.toBeDefined();
expect(res.npmToken).not.toBeDefined();
expect(res.npmrc).toEqual(
'//registry.npmjs.org/:_authToken=abcdef-ghijklm-nopqf-stuvwxyz\n'
'//registry.npmjs.org/:_authToken=abcdef-ghijklm-nopqf-stuvwxyz\n//registry.npmjs.org/:_authToken=abcdef-ghijklm-nopqf-stuvwxyz\n'
);
});
it('appends npm token in npmrc', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/config/decrypt.ts
Expand Up @@ -54,7 +54,7 @@ export function decryptConfig(
if (decryptedConfig.npmrc.includes('${NPM_TOKEN}')) {
logger.debug('Replacing ${NPM_TOKEN} with decrypted token');
decryptedConfig.npmrc = decryptedConfig.npmrc.replace(
'${NPM_TOKEN}',
/\${NPM_TOKEN}/g,
token
);
} else {
Expand Down

0 comments on commit 08de7af

Please sign in to comment.