Skip to content

Commit

Permalink
fix: fix a bug where an entry failed if the patches dir was missing (#56
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kormide authored Sep 25, 2023
1 parent 262c9e1 commit 9ad8490
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/domain/create-entry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ beforeEach(() => {
.map((f) => path.basename(f));
}) as any);

mocked(fs.existsSync).mockImplementation(((path: string) => {
if (path in mockedFileReads) {
mocked(fs.existsSync).mockImplementation(((p: string) => {
if (p in mockedFileReads) {
return true;
}
for (const f of Object.keys(mockedFileReads)) {
if (path.dirname(f) == p) {
return true;
}
}
return (jest.requireActual("node:fs") as any).existsSync(path);
}) as any);

Expand Down
3 changes: 3 additions & 0 deletions src/domain/create-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export class CreateEntryService {
moduleRoot: string
): void {
const patchesPath = rulesetRepo.patchesPath(moduleRoot);
if (!fs.existsSync(patchesPath)) {
return;
}
const patches = fs
.readdirSync(patchesPath)
.filter((f) => f.endsWith(".patch"));
Expand Down

0 comments on commit 9ad8490

Please sign in to comment.