Skip to content

Commit

Permalink
chore(verify): allow omit NUGET_TOKEN for skipPublishToNuget
Browse files Browse the repository at this point in the history
allows to omit NUGET_TOKEN if skipPublishToNuget is set to true
  • Loading branch information
Kampfmoehre committed Jul 13, 2022
1 parent ce6421d commit ecbe94d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ const SRError = require("@semantic-release/error");

export const verify = async (pluginConfig: Config & UserConfig, _context: Context): Promise<void> => {
const errors: Error[] = [];
for (const envVar of ["NUGET_TOKEN"]) {
if (!process.env[envVar]) {
errors.push(new Error(`Environment variable ${envVar} is not set.`));
}
if (!pluginConfig.skipPublishToNuget && !process.env["NUGET_TOKEN"]) {
errors.push(new Error("Environment variable NUGET_TOKEN is not set."));
}

if (pluginConfig.publishToGitLab) {
Expand Down
14 changes: 14 additions & 0 deletions test/verify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,18 @@ describe("verify", () => {
expect(actualErr).toBeDefined();
expect(actualErr?.details).toBe("Unable to find dotnet executable in dotnet");
});

it("should not complain about missing NUGET_TOKEN when skipPublishToNuget is true", async () => {
delete process.env.NUGET_TOKEN;
process.env.CI_SERVER_URL = "gitlab.com";
process.env.CI_PROJECT_ID = "132";
process.env.CI_JOB_TOKEN = "a3lhjli";

const promise = verify(
{ projectPath: "test/fixture/some.csproj", skipPublishToNuget: true, publishToGitLab: true } as UserConfig,
context,
);

await expect(promise).resolves.toBeUndefined();
});
});

0 comments on commit ecbe94d

Please sign in to comment.