Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
doc: clarify fs.mkdtemp prefix argument
Per: #6142

Clarify the prefix argument.

Fixes: #6142
  • Loading branch information
jasnell committed May 17, 2016
commit 2aad1643b2aa39afb0721d21a241f6619a1ddc7e
31 changes: 31 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,37 @@ fs.mkdtemp('/tmp/foo-', (err, folder) => {
});
```

*Note*: the `fs.mkdtemp()` method will append the six randomly selected
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the six" or simply "six"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, beginning of the sentence. So, "The"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the six should be fine.

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`).

```js
// The parent directory for the new temporary directory
const tmp_dir = '/tmp';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we follow camel casing for js variables, right?


// This method is *INCORRECT*:
fs.mkdtemp(tmp_dir, (err, folder) => {
if (err) throw err;
console.log(folder);
// Will print something similar to `/tmp-abc123`.
// Note that a new temporary directory is created
// at the file system root rather than *within*
// the /tmp directory.
});

// This method is *CORRECT*:
const path = require('path');
fs.mkdtemp(tmp_dir + path.sep, (err, folder) => {
if (err) throw err;
console.log(folder);
// Will print something similar to `/tmp/abc123`.
// A new temporary directory is created within
// the /tmp directory.
});
```

## fs.mkdtempSync(template)

The synchronous version of [`fs.mkdtemp()`][]. Returns the created
Expand Down