šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

broccoli-tree-walker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-tree-walker

Broccoli wrapper over walk-sync and fs-tree-diff

1.0.1
latest
Source
npm
Version published
Weekly downloads
31
29.17%
Maintainers
1
Weekly downloads
Ā 
Created
Source

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 method `unlink`: Called when you remove the specified file
   */
  virtual unlink(filePath: string, rootPath: string): any

  /**
   * Virtual method `rmdir`: Called when you remove the specified folder
   */
  virtual rmdir(filePath: string, rootPath: string): any

  /**
   * Virtual method `mkdir`: Called when you create the specified folder
   */
  virtual mkdir(filePath: string, rootPath: string): any

  /**
   * Virtual method `create`: Called when you create the specified file
   */
  virtual create(filePath: string, rootPath: string): any

  /**
   * Virtual method `change`: Called when you update the specified file to reflect changes
   */
  virtual change(filePath: string, rootPath: string): any

  /**
   * Virtal method `nodesChanged` Called when a change has been made to one of the input nodes
   */
  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);
  }
}

Keywords

broccoli

FAQs

Package last updated on 25 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts