Nutella Peanut-Butter Marshmallow
Miss any of our Open RFC calls?Watch the recordings here! »

read-dir-deep

7.0.1 • Public • Published

read-dir-deep

npm Linux Build Status Windows Build Status Code Coverage

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

Install

npm i read-dir-deep

DownloadsWeekly Downloads

807

Version

7.0.1

License

MIT

Unpacked Size

24.3 kB

Total Files

19

Last publish

Collaborators

  • avatar