-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Add the fs.mkdtemp() function. #5333
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -522,6 +522,30 @@ to the completion callback. `mode` defaults to `0o777`. | |
|
|
||
| Synchronous mkdir(2). Returns `undefined`. | ||
|
|
||
| ## fs.mkdtemp(prefix, callback) | ||
|
|
||
| Creates a unique temporary directory. | ||
|
|
||
| Generates six random characters to be appended behind a required | ||
| `prefix` to create a unique temporary directory. | ||
|
|
||
| The created folder path is passed as a string to the callback's second | ||
| parameter. | ||
|
|
||
| Example: | ||
|
|
||
| ```js | ||
| fs.mkdtemp('/tmp/foo-', (err, folder) => { | ||
| console.log(folder); | ||
| // Prints: /tmp/foo-itXde2 | ||
| }); | ||
| ``` | ||
|
|
||
| ## fs.mkdtempSync(template) | ||
|
|
||
| The synchronous version of [`fs.mkdtemp()`][]. Returns the created | ||
| folder path. | ||
|
|
||
|
Member
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. Would prefer just duplicating the description of
Contributor
Author
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. Because this is what every other sync function description does? I'm all for verboseness in documentation, but I'm even more in favor of consistency.
Member
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. Yeah, I've been slowly working towards adding the verboseness. This is fine for now. We can expand it out later. |
||
| ## fs.open(path, flags[, mode], callback) | ||
|
|
||
| Asynchronous file open. See open(2). `flags` can be: | ||
|
|
||
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.
Indent error. You could put it on the same line as the console.log.
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.
See here as for why this indentation was chosen: #5333 (comment)