Skip to content

Commit cde3551

Browse files
committed
doc: update os.tmpdir() to discuss symlink results on macOS
Closes: #11422
1 parent 2f97e97 commit cde3551

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/api/os.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,18 @@ changes:
330330
Returns the operating system's default directory for temporary files as a
331331
string.
332332

333+
By default on macOS, the returned path is a symlink. To get the resolved path,
334+
use [`fs.realpath()`][] or [`fs.realpathSync()`][].
335+
336+
```js
337+
const tmpdirPath = os.tmpdir();
338+
339+
// For most use cases, it does not matter whether tmpdirPath is a symlink or not
340+
// but if it does matter, obtain a resolved path with fs.realpath() or
341+
// fs.realpathSync().
342+
const tmpdirResolvedPath = fs.realpathSync(tmpdirPath);
343+
```
344+
333345
## `os.totalmem()`
334346
<!-- YAML
335347
added: v0.3.3
@@ -1252,6 +1264,8 @@ The following process scheduling constants are exported by
12521264
</table>
12531265

12541266
[`SystemError`]: errors.html#errors_class_systemerror
1267+
[`fs.realpath()`]: fs.html#fs_fs_realpath_path_options_callback
1268+
[`fs.realpathSync()`]: fs.html#fs_fs_realpathsync_path_options
12551269
[`process.arch`]: process.html#process_process_arch
12561270
[`process.platform`]: process.html#process_process_platform
12571271
[Android building]: https://github.com/nodejs/node/blob/master/BUILDING.md#androidandroid-based-devices-eg-firefox-os

0 commit comments

Comments
 (0)