Skip to content

Commit

Permalink
fix(publish): Overwrite Yarn registry proxy when encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Oct 4, 2018
1 parent 06a9479 commit f7fdc77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions commands/publish/__tests__/publish-command.test.js
Expand Up @@ -251,6 +251,23 @@ Set {
expect.objectContaining({ registry })
);
});

it("overwrites yarn registry proxy with https://registry.npmjs.org/", async () => {
const testDir = await initFixture("normal");
const registry = "https://registry.yarnpkg.com";

await lernaPublish(testDir)("--registry", registry);

expect(npmPublish).toBeCalledWith(
expect.objectContaining({ name: "package-1" }),
undefined, // dist-tag
expect.objectContaining({ registry: "https://registry.npmjs.org/" })
);

const logMessages = loggingOutput("warn");
expect(logMessages).toContain("Yarn's registry proxy is broken, replacing with public npm registry");
expect(logMessages).toContain("If you don't have an npm token, you should exit and run `npm login`");
});
});

describe("--no-verify-access", () => {
Expand Down
7 changes: 7 additions & 0 deletions commands/publish/index.js
Expand Up @@ -73,6 +73,13 @@ class PublishCommand extends Command {
registry,
});

if (this.conf.get("registry") === "https://registry.yarnpkg.com") {
this.logger.warn("", "Yarn's registry proxy is broken, replacing with public npm registry");
this.logger.warn("", "If you don't have an npm token, you should exit and run `npm login`");

this.conf.set("registry", "https://registry.npmjs.org/", "cli");
}

// all consumers need a token
const auth = this.conf.getCredentialsByURI(this.conf.get("registry"));

Expand Down

0 comments on commit f7fdc77

Please sign in to comment.