Skip to content

Commit

Permalink
Don't explicitly throw in readme-lists-correct-yarn-version
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Jan 4, 2024
1 parent 404f75f commit ae3da2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/rules/readme-lists-correct-yarn-version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Rule: readme-lists-correct-yarn-version', () => {
});
});

it('throws if the template does not have the Yarn version listed in its README for some reason', async () => {
it('passes if the template does not have the Yarn version listed in its README for some reason', async () => {
expect.assertions(1);

await withinSandbox(async (sandbox) => {
Expand All @@ -101,14 +101,16 @@ describe('Rule: readme-lists-correct-yarn-version', () => {
'does not matter',
);

await expect(
readmeListsCorrectYarnVersion.execute({
template,
project,
pass,
fail,
}),
).rejects.toThrow("Could not find Yarn version in template's README");
const result = await readmeListsCorrectYarnVersion.execute({
template,
project,
pass,
fail,
});

expect(result).toStrictEqual({
passed: true,
});
});
});
});
4 changes: 3 additions & 1 deletion src/rules/readme-lists-correct-yarn-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export default buildRule({

const match = fileContentInTemplate.match(/Install \[Yarn .+?\]\(.+?\)/u);
if (!match?.[0]) {
throw new Error(
console.warn(
"Could not find Yarn version in template's README. This is not the fault of the project, but is rather a bug in a rule.",
);
return pass();
}

if (!fileContentInProject.includes(match[0])) {
return fail([
{
Expand Down

0 comments on commit ae3da2c

Please sign in to comment.