From 8c0cf1e8d5a803a6901e980fef72c87e0e6f5bdd Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 3 May 2018 21:51:03 -0700 Subject: [PATCH] doc: fix mkdtemp() documentation Several minor fixes to the entries for `mkdtemp()`. The most significant is that a mistaken use of `fs.mkdtemp()` is corrected to `fsPromises.mkdtemp()`. PR-URL: https://github.com/nodejs/node/pull/20512 Reviewed-By: Vse Mozhet Byt Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Shingo Inoue --- doc/api/fs.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index da2b263e163559..bace6d94836c23 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2064,8 +2064,6 @@ parameter. The optional `options` argument can be a string specifying an encoding, or an object with an `encoding` property specifying the character encoding to use. -Example: - ```js fs.mkdtemp(path.join(os.tmpdir(), 'foo-'), (err, folder) => { if (err) throw err; @@ -2077,7 +2075,7 @@ fs.mkdtemp(path.join(os.tmpdir(), 'foo-'), (err, folder) => { The `fs.mkdtemp()` method will append the six randomly selected characters directly to the `prefix` string. For instance, given a directory `/tmp`, if the intention is to create a temporary directory *within* `/tmp`, the `prefix` -*must* end with a trailing platform-specific path separator +must end with a trailing platform-specific path separator (`require('path').sep`). ```js @@ -4003,24 +4001,22 @@ added: v10.0.0 * `encoding` {string} **Default:** `'utf8'` * Returns: {Promise} -Creates a unique temporary directory then resolves the `Promise` with the -created folder path. A unique directory name is generated by appending six -random characters to the end of the provided `prefix`. +Creates a unique temporary directory and resolves the `Promise` with the created +folder path. A unique directory name is generated by appending six random +characters to the end of the provided `prefix`. The optional `options` argument can be a string specifying an encoding, or an object with an `encoding` property specifying the character encoding to use. -Example: - ```js fsPromises.mkdtemp(path.join(os.tmpdir(), 'foo-')) .catch(console.error); ``` -The `fs.mkdtemp()` method will append the six randomly selected characters -directly to the `prefix` string. For instance, given a directory `/tmp`, if the -intention is to create a temporary directory *within* `/tmp`, the `prefix` -*must* end with a trailing platform-specific path separator +The `fsPromises.mkdtemp()` method will append the six randomly selected +characters directly to the `prefix` string. For instance, given a directory +`/tmp`, if the intention is to create a temporary directory *within* `/tmp`, the +`prefix` must end with a trailing platform-specific path separator (`require('path').sep`). ### fsPromises.open(path, flags[, mode])