From acb0d012b303c734c47c5ea9e758132181187703 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Thu, 14 Sep 2017 14:26:42 +0200 Subject: [PATCH] doc: make mkdtemp example work on Windows PR-URL: https://github.com/nodejs/node/pull/15408 Fixes: https://github.com/nodejs/node/issues/14960 Reviewed-By: Colin Ihrig Reviewed-By: Vse Mozhet Byt Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- doc/api/fs.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 0d9755d60900d3..034817b8b3bce7 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1536,10 +1536,10 @@ object with an `encoding` property specifying the character encoding to use. Example: ```js -fs.mkdtemp('/tmp/foo-', (err, folder) => { +fs.mkdtemp(path.join(os.tmpdir(), 'foo-'), (err, folder) => { if (err) throw err; console.log(folder); - // Prints: /tmp/foo-itXde2 + // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2 }); ``` @@ -1551,7 +1551,7 @@ the `prefix` *must* end with a trailing platform-specific path separator ```js // The parent directory for the new temporary directory -const tmpDir = '/tmp'; +const tmpDir = os.tmpdir(); // This method is *INCORRECT*: fs.mkdtemp(tmpDir, (err, folder) => {