Manages src tree traversal

Usage no npm install needed!

<script type="module">
  import broccoliTreeTraverser from '';



Manages src tree navigation, letting you deal with each file.

The traverser takes a path and a Visitor.

It traverses the input path, calling visitor#visit for each file it finds.


A visitor can be any object with a visit method. the visit method takes a file path (string) located somewhere along the input path. It should return a promise if it does anything asynchronously.

Future enhancements


The traversal algorithm is an in-order traversal. That is, it traverses files and directories in the order returned by fs.readdir. Feel free to submit pull requests with other traversal algorithms.

Visit Directories

The traverser only calls visit for plain files. Feel free to submit pull requests if you want to visit directories.

Example use

In a Brocfile:

var traverser = require('broccoli-tree-traverser');

var visitor = {
    console.log('visiting', path);  

module.exports = traverser('interesting/path', visitor);

Within another plugin

var traverser = require('broccoli-tree-traverser');

function MyPlugin(inputTree){
  this.traverser = traverser(inputTree, this);

MyPlugin.prototype.visit = function(path){
  //do something interesting with the path
}; = function(readTree){
  return readTree(this.traverser);

module.exports = MyPlugin;