Skip to content

Commit f0c55e2

Browse files
anonrigtargos
authored andcommittedOct 2, 2024
fs: refactor rimraf to avoid using primordials
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>
1 parent 0dd4639 commit f0c55e2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎lib/internal/fs/rimraf.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ function _rmchildren(path, options, callback) {
140140

141141
let done = false;
142142

143-
ArrayPrototypeForEach(files, (child) => {
144-
const childPath = Buffer.concat([pathBuf, separator, child]);
143+
const childPathPrefix = Buffer.concat([pathBuf, separator]);
144+
145+
for (let i = 0; i < files.length; i++) {
146+
const childPath = Buffer.concat([childPathPrefix, files[i]]);
145147

146148
rimraf(childPath, options, (err) => {
147149
if (done)
@@ -156,7 +158,7 @@ function _rmchildren(path, options, callback) {
156158
if (numFiles === 0)
157159
rmdir(path, callback);
158160
});
159-
});
161+
}
160162
});
161163
}
162164

0 commit comments

Comments
 (0)
Please sign in to comment.