Skip to content

Commit

Permalink
refactor: update getConfig errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BinToss committed May 28, 2024
1 parent 265ba9d commit cdcc110
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/semanticReleaseConfigDotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ export function getConfig(projectsToPublish: string[] = [], projectsToPackAndPus
if (projectsToPublish.length === 0) {
const _ = process.env["PROJECTS_TO_PUBLISH"];
if (_ === undefined)
errors.push(new Error("projectsToPublish or PROJECTS_TO_PUBLISH must be defined."));
errors.push(new Error("projectsToPublish.length must be > 0 or PROJECTS_TO_PUBLISH must be defined and contain at least one path."));
else
projectsToPublish = _.split(';');
}

if (projectsToPackAndPush && projectsToPackAndPush.length) {
const _ = process.env["PROJECTS_TO_PACK_AND_PUSH"]
if (_ === undefined)
errors.push(new Error("projectsToPackAndPush or PROJECTS_TO_PACK_AND_PUSH must be defined."));
errors.push(new Error("projectsToPackAndPush.length must be > 0 or PROJECTS_TO_PACK_AND_PUSH must be defined and contain at least one path."));
else
projectsToPackAndPush = _.split(';');
}
Expand Down
6 changes: 3 additions & 3 deletions tests/configDotnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ await describe('configDotnet', async () => {
await describe('getConfig', async () => {
strictEqual(getConfig.name, 'getConfig');

await it('throws Error when projectsToPublish, projectsToPackAndPush are both empty arrays.', () => {
await it('throws Error when projectsToPublish is an empty array, projectsToPackAndPush are both empty arrays.', () => {
const actual = (() => {
try {
return getConfig([], []);
return getConfig([], false);
} catch (error) {
return error as Error;
}
})();
ok(actual instanceof Error)
strictEqual(actual.message, "Type of projectsToPublish (object) is not allowed. Expected a string[] where length > 0.")
strictEqual(actual.message, "getConfig cannot continue. One or more errors occurred.\nprojectsToPublish.length must be > 0 or PROJECTS_TO_PUBLISH must be defined and contain at least one path.")
})
});
});

0 comments on commit cdcc110

Please sign in to comment.