From 42fd6401c24509e94d75cca4a0ba3ad2665d5783 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 d6f04b28897706..1d1fdb8463ca8d 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -1176,15 +1176,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, );