Skip to content

fs.readdir recursive: is parentPath supposed to be the same as path? #51955

@jonschlinkert

Description

@jonschlinkert

Affected URL(s)

No response

Description of the problem

I'm curious what the purpose of parentPath is on Dirent objects when using fs.readdir or fs.readdirSync when both withFileTypes and recursive are set to true.

The reason for this issue is that I haven't found a situation where parentPath differs from path, it's always the same value. My hunch is that it's not supposed to be and there is probably a bug.

FWIW, I think it would be more useful to include the relative path versus parentPath, since parentPath is just the path.dirname(path) of each path, isn't it? If not, perhaps parentPath isn't the best name? Maybe it should be base or root or something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions