read-dir-deep
v8.0.0
Published
Returns a sorted recursive list of all files inside a directory
Downloads
3,082
Maintainers
Readme
read-dir-deep
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