Skip to content

bconnorwhite/read-dir-safe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


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;
}

Dev DependenciesDavid


License license

MIT


Related Packages