From 490f15a99bcf258147cb99cc70109841f683fb50 Mon Sep 17 00:00:00 2001 From: YieldRay <24633623+YieldRay@users.noreply.github.com> Date: Tue, 23 Jul 2024 19:56:18 +0800 Subject: [PATCH] fs: ensure consistency for mkdtemp in both fs and fs/promises MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port changes for mkdtemp from lib/fs.js to lib/internal/fs/promise.js, ensuring consistent behavior. Refs: https://github.com/nodejs/node/pull/51078 PR-URL: https://github.com/nodejs/node/pull/53776 Reviewed-By: Michaƫl Zasso Reviewed-By: Yagiz Nizipli Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: LiviaMedeiros --- lib/internal/fs/promises.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index c9e9c840de3b70..df5cfab361b114 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -1179,15 +1179,8 @@ async function mkdtemp(prefix, options) { prefix = getValidatedPath(prefix, 'prefix'); warnOnNonPortableTemplate(prefix); - let path; - if (typeof prefix === 'string') { - path = `${prefix}XXXXXX`; - } else { - path = Buffer.concat([prefix, Buffer.from('XXXXXX')]); - } - return await PromisePrototypeThen( - binding.mkdtemp(path, options.encoding, kUsePromises), + binding.mkdtemp(prefix, options.encoding, kUsePromises), undefined, handleErrorFromBinding, );