broccoli-tree-walker
Helper base class for Broccoli plugins wraps fs-tree-diff and
node-walk-sync providing different methods based off of different
file operations.
API
class TreeWalker {
virtual unlink(filePath: string, rootPath: string): any
virtual rmdir(filePath: string, rootPath: string): any
virtual mkdir(filePath: string, rootPath: string): any
virtual create(filePath: string, rootPath: string): any
virtual change(filePath: string, rootPath: string): any
virtual nodesChanged(patchResults: Array<FSTree.Patch>): any
}
Options
All options except name
and annotation
can also be set on the prototype
instead of being passed into the constructor.
Example Usage
const TreeWalker = require('broccoli-tree-walker');
class FileWriter extends Walker {
_fileContents() {
return `/* some file contents */`;
}
create(filePath) {
const fullFilePath = path.join(this.outputPath, filePath);
return fs.outputFileSync(fullFilePath, this._someFileContents(filePath));
}
unlink(filePath) {
const fullFilePath = path.join(this.outputPath, filePath);
return fs.removeSync(fullFilePath);
}
}