Skip to content

Commit

Permalink
trigger npmrc validation
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Mar 15, 2021
1 parent 6f883b0 commit 614945d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions plugins/npm/__tests__/npm-next.test.ts
Expand Up @@ -262,6 +262,7 @@ describe("next", () => {
},
]);
execPromise.mockResolvedValueOnce("");
execPromise.mockResolvedValueOnce("");
execPromise.mockResolvedValueOnce("1.2.4-next.0");

plugin.apply(({
Expand Down Expand Up @@ -330,6 +331,7 @@ describe("next", () => {
]);
// isMonorepo
execPromise.mockResolvedValueOnce("");
execPromise.mockResolvedValueOnce("");
execPromise.mockResolvedValueOnce("1.2.4-next.0");

plugin.apply(({
Expand Down
13 changes: 7 additions & 6 deletions plugins/npm/__tests__/npm.test.ts
Expand Up @@ -824,7 +824,7 @@ describe("canary", () => {
canaryIdentifier: "canary.123.1",
});
expect(execPromise.mock.calls[1]).toContain("npm");
expect(execPromise.mock.calls[1][1]).toContain("1.2.4-canary.123.1.0");
expect(execPromise.mock.calls[2][1]).toContain("1.2.4-canary.123.1.0");
});

test("prints canary version in dry run", async () => {
Expand Down Expand Up @@ -924,15 +924,16 @@ describe("canary", () => {

// first version exists
execPromise.mockReturnValueOnce(true);
execPromise.mockReturnValueOnce(true);
// second doesn't
execPromise.mockReturnValueOnce(false);

await hooks.canary.promise({
bump: Auto.SEMVER.patch,
canaryIdentifier: "canary.123.1",
});
expect(execPromise.mock.calls[2]).toContain("npm");
expect(execPromise.mock.calls[2][1]).toContain("1.2.4-canary.123.1.1");
expect(execPromise.mock.calls[3]).toContain("npm");
expect(execPromise.mock.calls[3][1]).toContain("1.2.4-canary.123.1.1");
});

test("legacy auth work", async () => {
Expand Down Expand Up @@ -1000,8 +1001,8 @@ describe("canary", () => {
bump: Auto.SEMVER.patch,
canaryIdentifier: "canary.123.1",
});
expect(execPromise.mock.calls[1]).toContain("npm");
expect(execPromise.mock.calls[1][1]).toContain("1.2.4-canary.123.1.0");
expect(execPromise.mock.calls[2]).toContain("npm");
expect(execPromise.mock.calls[2][1]).toContain("1.2.4-canary.123.1.0");
});

test("use lerna for monorepo package", async () => {
Expand Down Expand Up @@ -1040,7 +1041,7 @@ describe("canary", () => {
bump: Auto.SEMVER.patch,
canaryIdentifier: "",
});
expect(execPromise.mock.calls[1][1]).toContain("lerna");
expect(execPromise.mock.calls[2][1]).toContain("lerna");
// @ts-ignore
expect(value.newVersion).toBe("1.2.3-canary.0");
});
Expand Down
2 changes: 2 additions & 0 deletions plugins/npm/src/index.ts
Expand Up @@ -1501,6 +1501,8 @@ export default class NPMPlugin implements IPlugin {
private async setTokenOnCI(auto: Auto) {
try {
await setTokenOnCI(auto.logger);
// This will make NPM actually check if the npmrc is valid for the env
await execPromise("npm", ["root"]);
} catch (error) {
if (
// eslint-disable-next-line no-template-curly-in-string
Expand Down

0 comments on commit 614945d

Please sign in to comment.