npm

Need private packages and team management tools?Check out npm Orgs. »

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.

install

npm i pedestrian

Downloadsweekly downloads

202

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability