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: #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 authored and aduh95 committed Sep 13, 2024
1 parent 31d4ef9 commit 375cbb5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/internal/fs/rimraf.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,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 @@ -155,7 +157,7 @@ function _rmchildren(path, options, callback) {
if (numFiles === 0)
rmdir(path, callback);
});
});
}
});
}

Expand Down

0 comments on commit 375cbb5

Please sign in to comment.