Skip to content

Commit 375cbb5

Browse files
anonrigaduh95
authored andcommitted
fs: refactor rimraf to avoid using primordials
PR-URL: #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]>
1 parent 31d4ef9 commit 375cbb5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/internal/fs/rimraf.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ function _rmchildren(path, options, callback) {
139139

140140
let done = false;
141141

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

145147
rimraf(childPath, options, (err) => {
146148
if (done)
@@ -155,7 +157,7 @@ function _rmchildren(path, options, callback) {
155157
if (numFiles === 0)
156158
rmdir(path, callback);
157159
});
158-
});
160+
}
159161
});
160162
}
161163

0 commit comments

Comments
 (0)