Skip to content
Permalink
Browse files

fix: set npm config to read NPM_AUTH_TOKEN (#923)

Co-authored-by: shipjs <shipjs@test.com>
  • Loading branch information
eunjae-lee and shipjs committed Sep 10, 2020
1 parent de3df55 commit 1c935a354fb167a3fd5bc9587c857ec338df59db
@@ -19,8 +19,15 @@ describe('runPublish', () => {
dir: '.',
dryRun: false,
});
expect(run).toHaveBeenCalledTimes(1);
expect(run).toHaveBeenCalledTimes(2);
expect(run.mock.calls[0][0]).toMatchInlineSnapshot(`
Object {
"command": "npm config set \\"//registry.npmjs.org/:_authToken\\" \\"\\\\\${NPM_AUTH_TOKEN}\\"",
"dir": ".",
"dryRun": false,
}
`);
expect(run.mock.calls[1][0]).toMatchInlineSnapshot(`
Object {
"command": "npm_config_registry=https://registry.npmjs.org/ npm publish --tag latest",
"dir": ".",
@@ -39,8 +46,15 @@ describe('runPublish', () => {
dir: '.',
dryRun: false,
});
expect(run).toHaveBeenCalledTimes(1);
expect(run).toHaveBeenCalledTimes(2);
expect(run.mock.calls[0][0]).toMatchInlineSnapshot(`
Object {
"command": "npm config set \\"//registry.npmjs.org/:_authToken\\" \\"\\\\\${NPM_AUTH_TOKEN}\\"",
"dir": ".",
"dryRun": false,
}
`);
expect(run.mock.calls[1][0]).toMatchInlineSnapshot(`
Object {
"command": "npm publish --tag latest",
"dir": ".",
@@ -73,15 +87,22 @@ describe('runPublish', () => {
"Running the following at /package-b",
]
`);
expect(run).toHaveBeenCalledTimes(2);
expect(run).toHaveBeenCalledTimes(3);
expect(run.mock.calls[0][0]).toMatchInlineSnapshot(`
Object {
"command": "npm config set \\"//registry.npmjs.org/:_authToken\\" \\"\\\\\${NPM_AUTH_TOKEN}\\"",
"dir": ".",
"dryRun": false,
}
`);
expect(run.mock.calls[1][0]).toMatchInlineSnapshot(`
Object {
"command": "npm_config_registry=https://registry.npmjs.org/ npm publish --tag latest",
"dir": "/package-a",
"dryRun": false,
}
`);
expect(run.mock.calls[1][0]).toMatchInlineSnapshot(`
expect(run.mock.calls[2][0]).toMatchInlineSnapshot(`
Object {
"command": "npm_config_registry=https://registry.npmjs.org/ npm publish --tag latest",
"dir": "/package-b",
@@ -8,6 +8,14 @@ export default ({ isYarn, config, releaseTag: tag, dir, dryRun }) =>
runStep({ title: 'Publishing.' }, () => {
const { publishCommand, monorepo } = config;

// This adds the following line to ~/.npmrc
// > registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
run({
command: `npm config set "//registry.npmjs.org/:_authToken" "\\\${NPM_AUTH_TOKEN}"`,
dir,
dryRun,
});

if (monorepo) {
const { packagesToPublish } = monorepo;
const packageList = expandPackageList(packagesToPublish, dir);

0 comments on commit 1c935a3

Please sign in to comment.
You can’t perform that action at this time.