Skip to content

faker.system.directoryPath should have a "depth" option #3785

@lriggle-strib

Description

@lriggle-strib

Clear and concise description of the problem

When generating a path using faker.system.directoryPath there should be an option to specify how "deep" of a. path should be generated.

Suggested solution

Add parameters to the function that allows the user to specify how deep of a directory path they want generated.

Depth examples:

  • 0: /
  • 1: /etc, or /usr
  • 2: /etc/mail or /usr/lib
  • 3: /usr/lib/log

Depth value could be passed either as a parameter, or as part of an "options" object

const asParameter = faker.system.directoryPath(3);

const asOptionsObject = faker.system.directoryPath({ depth: 3 });

If no depth parameter is included, function would behave as it does today.

Alternative

No response

Additional context

This functionality would be extremely useful when generating test data for parent/child path structures. For example, if I'm generating something with a path of /x/y/z, and the structure includes a "parent" property, it would be easier to generate a value that could be used to set both if the depth of the directory structure could be set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: featureRequest for new featurehas workaroundWorkaround provided or linkedm: systemSomething is referring to the system modules: waiting for user interestWaiting for more users interested in this feature
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions