paths-resolve
v1.1.1
Published
Recursively walk through a directory and return files absolute paths
Downloads
6
Maintainers
Readme
paths-resolve
A simple function with no extra dependencies to recursively walk through a directory and sub-directories. It returns an array of absolute paths to files.
Useful for bootstrapping.
npm install --save paths-resolve
Usage:
const pathsResolve = require('paths-resolve');
let files = pathsResolve(__dirname, { extensions: ['.js', '.json'], exclude: ['index.js', 'package.json'] });
console.log(files);
output something like:
[
'/var/projects/my-project/file.js',
'/var/projects/my-project/my-subdir/file.json',
'/var/projects/my-project/my-subdir/file.js'
]
Options:
extensions: []
allowed extensions (.js, .json, .whatever, ...)
exclude: []
exclude files (index.js, something.json, etc...)
onFound: (absolutePath) => absolutePath
act on value before it is pushed and returned. Always return or you'll get undefined.