Skip to content

Commit

Permalink
docs: add docs & types for withRelativePaths
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Jan 18, 2022
1 parent bd96d22 commit 65f790b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
10 changes: 10 additions & 0 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ Use this to get full absolute paths in the output.
const crawler = new fdir().withFullPaths();
```

### `withRelativePaths`

Use this to get paths relative to the root directory in the output.

**Usage**

```js
const crawler = new fdir().withRelativePaths();
```

### `withErrors`

Use this if you want to handle all errors manually.
Expand Down
20 changes: 13 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ declare module "fdir" {
export type OnlyCountsOutput = { files: number; dirs: number };
export type PathsOutput = string[];

type FilterFn = (path: string, isDirectory: boolean) => boolean;
type ExcludeFn = (dirName: string, dirPath: string) => boolean;
type Callback = (error: Error, output: Output) => void;
export type FilterFn = (path: string, isDirectory: boolean) => boolean;
export type ExcludeFn = (dirName: string, dirPath: string) => boolean;
export type Callback = (error: Error, output: Output) => void;

type Group = { dir: string; files: string[] };
export type Group = { dir: string; files: string[] };

type Output = GroupOutput | OnlyCountsOutput | PathsOutput;
export type Output = GroupOutput | OnlyCountsOutput | PathsOutput;

type Options = {
export type Options = {
includeBasePath?: boolean;
includeDirs?: boolean;
normalizePath?: boolean;
Expand All @@ -24,6 +24,7 @@ declare module "fdir" {
resolveSymlinks?: boolean;
excludeFiles?: boolean;
exclude?: ExcludeFn;
relativePaths?: boolean;
};

class APIBuilder {
Expand Down Expand Up @@ -58,7 +59,12 @@ declare module "fdir" {
/**
* Resolve and recurse over all symlinks
*/
withSymlinks(): Builder;
withSymlinks(): Builder;

/**
* Return paths relative to the root directory
*/
withRelativePaths(): Builder;

/**
* The depth to crawl to before stopping
Expand Down

0 comments on commit 65f790b

Please sign in to comment.