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 <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
anonrig authored 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.