Skip to content

Commit f0c55e2

Browse files
anonrigtargos
authored andcommitted
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

Lines changed: 5 additions & 3 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy