fix: 替换所有测试文件的 rm 为 retryRm,修复 Windows EBUSY
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
import { rm } from "node:fs/promises";
|
||||
import { rm as fsRm } from "node:fs/promises";
|
||||
|
||||
const RETRY_CODES = new Set(["EBUSY", "EPERM"]);
|
||||
|
||||
export async function retryRm(
|
||||
path: string,
|
||||
{ maxRetries = 5, baseDelay = 100 }: { maxRetries?: number; baseDelay?: number } = {},
|
||||
{
|
||||
maxRetries = 5,
|
||||
baseDelay = 100,
|
||||
_rm = fsRm,
|
||||
}: { maxRetries?: number; baseDelay?: number; _rm?: typeof fsRm } = {},
|
||||
): Promise<void> {
|
||||
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
await rm(path, { recursive: true, force: true });
|
||||
await _rm(path, { recursive: true, force: true });
|
||||
return;
|
||||
} catch (err: any) {
|
||||
if (!RETRY_CODES.has(err.code) || attempt === maxRetries) {
|
||||
|
||||
Reference in New Issue
Block a user