1.0.1 • Published 4 years ago

read-dir-safe v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Read directories recursively or non-recursively.

  • Returns an array of relative file paths.
  • Rather than throwing, returns undefined on errors for the root directory you are reading (for example, if you try to read a directory that does not exist).

Installation

yarn add read-dir-safe
npm install read-dir-safe

API

import { readDir, readDirSync, Options } from "read-dir-safe";

function readDir(path: string, options: Options): Promise<string[] | undefined>;

function readDirSync(path: string, options: Options): string[] | undefined;

type Options = {
  /**
   * Recursively read child directories as well. Default: `true`
   */
  recursive?: boolean;
  /**
   * Whether to include directories in the results. Default: `false`
   */
  includeDirectories?: boolean;
}

MIT

Related Packages