# read-dir-deep

> Returns a sorted recursive list of all files inside a directory

Latest version **8.0.0** (published 2023-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install read-dir-deep
pnpm add read-dir-deep
yarn add read-dir-deep
bun add read-dir-deep
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.0.0 |
| Published | 2023-11-15 |
| First published | 2018-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.12.0 |
| Dependencies | 5 |
| Unpacked size | 23.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Chris Blossom |
| Maintainers | chrisblossom |
| Keywords | directory, folder, dir, ls, ll, file, list, recursive, deep, globby, glob |

## Links

- npm: https://www.npmjs.com/package/read-dir-deep
- Repository: https://github.com/chrisblossom/read-dir-deep
- Issues: https://github.com/chrisblossom/read-dir-deep/issues
- npm.io page: https://npm.io/package/read-dir-deep

## Dependencies (5)

- [slash](https://npm.io/package/slash.md) ^3.0.0
- [globby](https://npm.io/package/globby.md) ^11.1.0
- [path-sort2](https://npm.io/package/path-sort2.md) ^1.0.0
- [is-path-cwd](https://npm.io/package/is-path-cwd.md) ^2.2.0
- [is-path-in-cwd](https://npm.io/package/is-path-in-cwd.md) ^3.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 8.0.0 (latest) — 2023-11-15
- 7.0.1 — 2019-07-10
- 7.0.0 — 2019-07-10
- 6.0.1 — 2019-06-25
- 6.0.0 — 2019-05-17
- 5.0.0 — 2019-04-22
- 4.0.4 — 2019-04-22
- 4.0.3 — 2019-03-04
- 4.0.2 — 2019-01-15
- 4.0.1 — 2019-01-15
- 4.0.0 — 2019-01-15
- 3.0.0 — 2019-01-08
- 2.0.0 — 2019-01-05
- 1.0.6 — 2019-01-05
- 1.0.5 — 2019-01-04
- … 5 more at https://npm.io/package/read-dir-deep/versions

## README

# read-dir-deep

[![npm](https://img.shields.io/npm/v/read-dir-deep.svg?label=npm%20version)](https://www.npmjs.com/package/read-dir-deep)

## About

Returns a sorted recursive list of all files inside a directory.

## Installation

`npm install --save read-dir-deep`

## Usage

```js
const path = require('path');
const { readDirDeep, readDirDeepSync } = require('read-dir-deep');

const rootDir = path.resolve(process.cwd(), 'nested');

// async
const files = await readDirDeep(rootDir);

// sync
const files = readDirDeepSync(rootDir);

console.log(files);
// [
//     'nested/a/b/c.js',
//     'nested/a.js',
//     'nested/b/a.js',
//     'nested/b.js',
// ]
```

## Options

```js
const files = await readDirDeep(rootDir, {
	/**
	 * Return files relative to this directory
	 *
	 * defaults:
	 *    inside process.cwd(): process.cwd()
	 *    outside process.cwd(): rootDir
	 */
	cwd: process.cwd(),

	/**
	 * Return full file paths
	 *
	 * defaults:
	 *     inside process.cwd: false
	 *     outside process.cwd: true
	 */
	absolute: true,

	/**
	 * Custom file matching
	 *
	 * See [globby#patterns](https://github.com/sindresorhus/globby#patterns)
	 *
	 * default: ['.']
	 */
	patterns: [
		'.',
		'!**/*.test.js',
	],

	/**
	 * Exclude files/folders
	 *
	 * default: see below
	 * See named export: defaultIgnorePatterns
	 */
	ignore: [
		'**/.DS_Store',
		'**/node_modules/**',
		'**/.git/**',
		'**/.vscode/**',
		'**/.idea/**',
		'**/dist/**',
		'**/build/**',
		'**/coverage/**',
	],

	/**
	 * Exclude files set in .gitignore
	 *
	 * default: true
	 */
	gitignore: true,
});
```

See [Globby Options](https://github.com/sindresorhus/globby#options) for additional options

## Thanks To / Related Projects

-   [sindresorhus/globby](https://github.com/sindresorhus/globby)
-   [hughsk/path-sort](https://github.com/hughsk/path-sort)

---
_Source: https://npm.io/package/read-dir-deep · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
