pedestrian

2.0.0 • Public • Published

Build Status downloads npm Code Climate Test Coverage dependencies

Pedestrian

A recursive file walker for node.js

Installation

npm install pedestrian --save

Usage

Synchronously or asynchronously walk a file tree and receive an array of files back.

API

walk(directory[, patterns])

Walk a file tree asynchronously. This function returns a promise.

const pedestrian = require('pedestrian');
 
pedestrian.walk('dir').then(files => {
 
}, err => {
 
});

Or to get only particular files, pass one or more glob patterns as the second argument.

pedestrian.walk('dir', '**/*.js').then(files => {
 
});
 
// or
 
pedestrian.walk('dir', ['*.js', '*.coffee']).then(files => {
 
});

Negative globs are also supported.

pedestrian.walk('dir', ['**/*.js', '!**/foo.js']).then(files => {
 
});

walkSync(directory[, patterns])

The api for walkSync is the same as for walk, but instead of returning a promise, it returns the array of files.

let files = pedestrian.walkSync('lib');

N.B.

Both the sync and async versions work with either absolute or relatives paths. Relative paths should be relative to the caller, rather than the current working directory. The files that pedestrian returns will always be absolute paths, however.

See minimatch for more on the kinds of patterns you can use.

Contributing

Please see the contribution guidelines.

Package Sidebar

Install

npm i pedestrian

Weekly Downloads

8

Version

2.0.0

License

MIT

Last publish

Collaborators

  • tandrewnichols
  • mantacode