read-dir-safe
v1.0.1
Published
Read directories recursively or non-recursively
Downloads
922
Readme
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;
}
- @bconnorwhite/bob: Bob is a toolkit for typescript projects
- @types/mock-fs: TypeScript definitions for mock-fs
- @types/node: TypeScript definitions for Node.js
- mock-fs: A configurable mock file system. You know, for testing.
Related Packages
- fs-safe: A simple fs wrapper that doesn't throw
- write-dir-safe: Create directories and their parents recursively
- remove-dir-safe: Remove directories recursively or non-recursively
- read-file-safe: Read files without try catch
- write-file-safe: Write files, and parent directories if necessary
- remove-file-safe: Remove a file without try catch