fs: refactor rimraf to avoid using primordials

PR-URL: https://github.com/nodejs/node/pull/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>
pull/54879/head
Yagiz Nizipli 2024-09-09 22:32:57 -04:00 committed by GitHub
parent 2ef33af16e
commit 741004a3b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 4 deletions

View File

@ -7,7 +7,6 @@
'use strict';
const {
ArrayPrototypeForEach,
Promise,
SafeSet,
} = primordials;
@ -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)
@ -148,7 +149,7 @@ function _rmchildren(path, options, callback) {
if (numFiles === 0)
rmdir(path, callback);
});
});
}
});
}