Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.42 KB

DOCUMENTATION.md

File metadata and controls

40 lines (30 loc) · 1.42 KB

Documentation

You can see below the API reference of this module.

ParentSearch(path, search, options, callback, progress)

Searches a file/directory in parent directories.

Having the following file structure:

.
├── example
│   └── some
│       └── dir
└── package.json

Supposing you want to find the path to the first package.json file, starting with example/some/dir, just do ParentSearch("path/to/some/dir", "package.json")

Params

  • String path: The start directory path.

  • String search: The file/directory to search.

  • Object options: An object containing the following fields:

  • multiple (Boolean): If true, the search will stop only when it reaches the root directory (default: false).

  • obj (Boolean): If true, the results will be objects, otherwise they will be strings.

  • Function callback: The callback function. If not provided, the sync version will be used instead. This is called with an error in first argument and location object/string of the found file/directory.

  • Function progress: The progress function. This is called with an object when the file/directory is found. The object contains:

  • d: The directory path of the found path.

  • b: The basename.

  • p: The absolute path to the file/directory.

  • _: The directory of searched path.

Return

  • Array|String|Object The location(s) that were found.