Skip to content

Commit

Permalink
fs: ensure consistency for mkdtemp in both fs and fs/promises
Browse files Browse the repository at this point in the history
Port changes for mkdtemp from lib/fs.js to lib/internal/fs/promise.js,
ensuring consistent behavior.

Refs: #51078
PR-URL: #53776
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
  • Loading branch information
YieldRay authored and RafaelGSS committed Aug 5, 2024
1 parent 2c44706 commit e0054ee
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -1175,15 +1175,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,
);
Expand Down

0 comments on commit e0054ee

Please sign in to comment.