diff --git a/plugins/npm/__tests__/npm-next.test.ts b/plugins/npm/__tests__/npm-next.test.ts index 1ffeeb57f..2a4338540 100644 --- a/plugins/npm/__tests__/npm-next.test.ts +++ b/plugins/npm/__tests__/npm-next.test.ts @@ -262,6 +262,7 @@ describe("next", () => { }, ]); execPromise.mockResolvedValueOnce(""); + execPromise.mockResolvedValueOnce(""); execPromise.mockResolvedValueOnce("1.2.4-next.0"); plugin.apply(({ @@ -330,6 +331,7 @@ describe("next", () => { ]); // isMonorepo execPromise.mockResolvedValueOnce(""); + execPromise.mockResolvedValueOnce(""); execPromise.mockResolvedValueOnce("1.2.4-next.0"); plugin.apply(({ diff --git a/plugins/npm/__tests__/npm.test.ts b/plugins/npm/__tests__/npm.test.ts index 00c360f2f..576868595 100644 --- a/plugins/npm/__tests__/npm.test.ts +++ b/plugins/npm/__tests__/npm.test.ts @@ -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 () => { @@ -924,6 +924,7 @@ describe("canary", () => { // first version exists execPromise.mockReturnValueOnce(true); + execPromise.mockReturnValueOnce(true); // second doesn't execPromise.mockReturnValueOnce(false); @@ -931,8 +932,8 @@ describe("canary", () => { 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 () => { @@ -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 () => { @@ -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"); }); diff --git a/plugins/npm/src/index.ts b/plugins/npm/src/index.ts index dd127e899..2acae069c 100644 --- a/plugins/npm/src/index.ts +++ b/plugins/npm/src/index.ts @@ -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