-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: make mkdtemp example work on Windows #15408
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1536,10 +1536,11 @@ object with an `encoding` property specifying the character encoding to use. | |
Example: | ||
|
||
```js | ||
fs.mkdtemp('/tmp/foo-', (err, folder) => { | ||
const tempFolder = process.platform === 'win32' ? process.env['TEMP'] : '/tmp'; | ||
fs.mkdtemp(path.join(tempFolder, '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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is also incorrect for macOS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be blocking though, right? As a comment it should be fine as is? (I do not have a Mac to test this on my own) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can confirm the tmp dir is different on macOS but ofc this comment should not block PR from landing. |
||
}); | ||
``` | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use
os.tmpDir()
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, updated.