Skip to content

Commit 2faece2

Browse files
authored
Merge pull request #4 from constructive-io/feat/clean-retry
fix: add maxRetries to fs.rm in clean to handle ENOTEMPTY race conditions
2 parents 9545726 + 73fb9c2 commit 2faece2

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/makage/__tests__/clean.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ describe('runClean', () => {
1414
it('should remove a single path', async () => {
1515
await runClean(['dist']);
1616

17-
expect(mockedFs.rm).toHaveBeenCalledWith('dist', { recursive: true, force: true });
17+
expect(mockedFs.rm).toHaveBeenCalledWith('dist', { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
1818
});
1919

2020
it('should remove multiple paths', async () => {
2121
await runClean(['dist', 'build', 'temp']);
2222

23-
expect(mockedFs.rm).toHaveBeenCalledWith('dist', { recursive: true, force: true });
24-
expect(mockedFs.rm).toHaveBeenCalledWith('build', { recursive: true, force: true });
25-
expect(mockedFs.rm).toHaveBeenCalledWith('temp', { recursive: true, force: true });
23+
expect(mockedFs.rm).toHaveBeenCalledWith('dist', { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
24+
expect(mockedFs.rm).toHaveBeenCalledWith('build', { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
25+
expect(mockedFs.rm).toHaveBeenCalledWith('temp', { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
2626
});
2727

2828
it('should default to "dist" if no paths provided', async () => {
2929
await runClean([]);
3030

31-
expect(mockedFs.rm).toHaveBeenCalledWith('dist', { recursive: true, force: true });
31+
expect(mockedFs.rm).toHaveBeenCalledWith('dist', { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
3232
});
3333
});

packages/makage/src/commands/clean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export async function runClean(paths: string[]) {
44
const pathsToClean = paths.length ? paths : ['dist'];
55

66
for (const p of pathsToClean) {
7-
await fs.rm(p, { recursive: true, force: true });
7+
await fs.rm(p, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
88
console.log(`[makage] removed ${p}`);
99
}
1010
}

0 commit comments

Comments
 (0)