An open API service indexing awesome lists of open source software.

https://github.com/rezigned/node-file-walker

Node.js module that recursively traversing files/directories
https://github.com/rezigned/node-file-walker

Last synced: about 1 year ago
JSON representation

Node.js module that recursively traversing files/directories

Awesome Lists containing this project

README

          

## A Simple file/directory traversal module

[![Build Status](https://travis-ci.org/rezigned/node-file-walker.png)](https://travis-ci.org/rezigned/node-file-walker)

### Installation

```
npm install file-walker
```

### Callback arguments

* files - an array of files/directories in current directory e.g. `['dummy', 'test.js']`
* dir - directory name e.g. `'./test'`
* level - Current directory level starting from `0`

### Example usage

Assume we have the following directory structure

```
./test/
+- a.js
+- b/
+- c.js
+- d.js
```

```js
var walk = require('file-walker');

walk('./directory', function(dir, files, level) {
// 1st iteration, level = 0, dir = './test', files = ['a.js', 'b']
// 2nd iteration, level = 1, dir = './test/b', files = ['c.js', 'd.js']
// your logic
});
```