Skip to content

Commit

Permalink
fs: refactor rimraf to avoid using primordials
Browse files Browse the repository at this point in the history
PR-URL: nodejs#54834
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
anonrig committed Sep 10, 2024
1 parent 2ef33af commit 741004a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/internal/fs/rimraf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
'use strict';

const {
ArrayPrototypeForEach,
Promise,
SafeSet,
} = primordials;
Expand Down Expand Up @@ -132,8 +131,10 @@ function _rmchildren(path, options, callback) {

let done = false;

ArrayPrototypeForEach(files, (child) => {
const childPath = Buffer.concat([pathBuf, separator, child]);
const childPathPrefix = Buffer.concat([pathBuf, separator]);

for (let i = 0; i < files.length; i++) {
const childPath = Buffer.concat([childPathPrefix, files[i]]);

rimraf(childPath, options, (err) => {
if (done)
Expand All @@ -148,7 +149,7 @@ function _rmchildren(path, options, callback) {
if (numFiles === 0)
rmdir(path, callback);
});
});
}
});
}

Expand Down

0 comments on commit 741004a

Please sign in to comment.