When tmp.dir() is called with the { dir: X } parameter, the final path of the temporary folder is automatically resolved (by _resolvePaths). This resolves any symlinks to their actual paths.
However, when called without any parameters, the final path isn't fully resolved.
This can cause issues on MacOS, as /var is a symlink to /private/var.
This means the following code:
const parentTmpDir = tmp.dirSync();
const childTmpDir = tmp.dirSync({ dir: parentTmpDir });
const relativePath = path.relative(parentTmpDir, childTmpDir);
Won't behave as expected, as childTmpDir isn't a subdirectory of parentTmpDir (as far as paths are concerned). You'd end up with something like:
parentTmpDir: /var/folder/X/Y/Z
childTmpDir: /private/var/folder/X/Y/Z
relativePath: ../../../../private/var/folder/X/Y/Z