From 9bdf2ee1d184e7ec5c690319e068894ed324b595 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 30 Aug 2024 20:44:26 +0200 Subject: [PATCH] doc: add documentation about os.tmpdir() overrides This documents the TMPDIR, TEMP and TMP overrides on different platforms and that some operating systems set these by default. PR-URL: https://github.com/nodejs/node/pull/54613 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Richard Lau Reviewed-By: Matteo Collina Reviewed-By: Luigi Pinca --- doc/api/os.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/api/os.md b/doc/api/os.md index fec69aaf47527a..01496812d7f488 100644 --- a/doc/api/os.md +++ b/doc/api/os.md @@ -416,6 +416,19 @@ changes: Returns the operating system's default directory for temporary files as a string. +On Windows, the result can be overridden by `TEMP` and `TMP` environment variables, and +`TEMP` takes precedence over `TMP`. If neither is set, it defaults to `%SystemRoot%\temp` +or `%windir%\temp`. + +On non-Windows platforms, `TMPDIR`, `TMP` and `TEMP` environment variables will be checked +to override the result of this method, in the described order. If none of them is set, it +defaults to `/tmp`. + +Some operating system distributions would either configure `TMPDIR` (non-Windows) or +`TEMP` and `TMP` (Windows) by default without additional configurations by the system +administrators. The result of `os.tmpdir()` typically reflects the system preference +unless it's explicitly overridden by the users. + ## `os.totalmem()`