Skip to content

Commit

Permalink
fix: replace deprecated fs.rmdir with recursive removal logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nexckycort committed Oct 8, 2024
1 parent 7e1b6f0 commit 4d6b4bc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/rspack/src/util/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import assert from "node:assert";
import type { Abortable } from "node:events";
import path from "node:path";
import type { RmOptions } from "node:fs";

import type { WatchOptions } from "../config";

Expand Down Expand Up @@ -96,9 +97,10 @@ export interface OutputFileSystem {
arg1?: (string | Buffer)[] | IDirent[]
) => void
) => void;
rmdir: (
rm: (
arg0: string,
arg1: (arg0?: null | NodeJS.ErrnoException) => void
arg1: RmOptions,
arg2: (arg0?: null | NodeJS.ErrnoException) => void
) => void;
unlink: (
arg0: string,
Expand Down Expand Up @@ -499,7 +501,7 @@ export function rmrf(
}
let count = files!.length;
if (count === 0) {
fs.rmdir(p, callback);
fs.rm(p, { recursive: true }, callback);
} else {
for (const file of files!) {
assert(typeof file === "string");
Expand All @@ -510,7 +512,7 @@ export function rmrf(
}
count--;
if (count === 0) {
fs.rmdir(p, callback);
fs.rm(p, { recursive: true }, callback);
}
});
}
Expand Down

0 comments on commit 4d6b4bc

Please sign in to comment.