这是indexloc提供的服务,不要输入任何密码
Skip to content

Paths are only fully resolved when specific parameters are provided #311

@Spoffy

Description

@Spoffy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions