Skip to content

Commit 741004a

Browse files
authoredSep 10, 2024
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 2ef33af commit 741004a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎lib/internal/fs/rimraf.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
'use strict';
88

99
const {
10-
ArrayPrototypeForEach,
1110
Promise,
1211
SafeSet,
1312
} = primordials;
@@ -132,8 +131,10 @@ function _rmchildren(path, options, callback) {
132131

133132
let done = false;
134133

135-
ArrayPrototypeForEach(files, (child) => {
136-
const childPath = Buffer.concat([pathBuf, separator, child]);
134+
const childPathPrefix = Buffer.concat([pathBuf, separator]);
135+
136+
for (let i = 0; i < files.length; i++) {
137+
const childPath = Buffer.concat([childPathPrefix, files[i]]);
137138

138139
rimraf(childPath, options, (err) => {
139140
if (done)
@@ -148,7 +149,7 @@ function _rmchildren(path, options, callback) {
148149
if (numFiles === 0)
149150
rmdir(path, callback);
150151
});
151-
});
152+
}
152153
});
153154
}
154155

0 commit comments

Comments
 (0)