šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Book a DemoInstallSign in
Socket

deep-list-dir

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-list-dir

Recursively lists given directory, alternatively filtering results with given options

1.4.4
latest
Source
npm
Version published
Weekly downloads
27
92.86%
Maintainers
1
Weekly downloads
Ā 
Created
Source

deep-list-dir

Deeply lists a directory filtering files by given pattern(s)

Version tests

This module recursively lists all files in given directory (including sub-folders) by early filtering the results using the given pattern which can be an array of minimatch expressions or RegExp.

It will return all matching results. minimatch negative patterns are used to explicitly exclude a path from being scan / returned.

Example

Take the following file structure:

<directory>
ā”œā”€ā”€ dir1
│   └── README.md
ā”œā”€ā”€ dir2
│   └── sub-dir2
│       ā”œā”€ā”€ hi.txt
│       └── index.js
ā”œā”€ā”€ index.js
└── README.md

...and the following script:

const { deepListDir, deepListDirSync } = require('deep-list-dir')

deepListDir('<directory>',
  {
    pattern: ['*.md'], // minimatch or RegExp
    // base: '', set parent base to something different than given directory
    // minimatchOptions: { matchBase: true } // minimatch options
  }
).then(console.log)

Will output

[
  "dir1/README.md",
  "README.md"
]

A sync version is also provided:

console.log(deepListDirSync('<directory>', { pattern: '*.js'})) 

Output:

[
  "dir2/sub-dir2/index.js",
  "index.js"
]

License

MIT

Ā© 2020-present Martin Rafael Gonzalez tin@devtin.io

Keywords

deep

FAQs

Package last updated on 06 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts