1.1.1 • Published 8 years ago

paths-resolve v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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.