Package detail

read-dir-deep

chrisblossom1kMIT8.0.0

Returns a sorted recursive list of all files inside a directory

directory, folder, dir, ls

readme

read-dir-deep

npm

About

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

Installation

npm install --save read-dir-deep

Usage

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

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 for additional options

Thanks To / Related Projects

changelog

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Moved to github releases.

[Unreleased]

[6.0.0] - 2019-05-17

  • Breaking: Remove node 6 support

[5.0.0] - 2019-04-22

Changed

  • Breaking: remove default export and add named exports: readDirDeep, readDirDeepSync
  • Breaking: replace readDirDeep.sync with named export readDirDeepSync
  • Update packages

[4.0.4] - 2019-04-22

Fixed

  • (Typescript) Options now correctly extends Globby's Options

[4.0.2] - 2019-01-15

Fixed

  • Fix Typescript return type

[4.0.1] - 2019-01-15

Fixed

  • Change default pattern to **. Correctly throw ENOTDIR fix

[4.0.0] - 2019-01-15

  • Migrate to Typescript
  • Breaking: Update globby

[3.0.0] - 2019-01-07

Changed

[2.0.0] - 2019-01-05

Changed

[1.0.6] - 2019-01-05

Changed

  • Add relative option
  • Internal: replace async for of with Promise.all(map)