Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

broccoli-glob-filter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-glob-filter

Base class for broccoli plugins that processes files one by one.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

broccoli-glob-filter

Base class for broccoli plugins that processes files one by one.

Features:

  • It stores results in the cache and rebuilds only changed files.
  • It supports glob patterns to specify files to filter.

Install

npm install broccoli-glob-filter

Usage

var Filter = require('broccoli-glob-filter')

var MyFilter = function(inputTree, options) {
  Filter.apply(this, arguments)
}
MyFilter.prototype = Object.create(Filter.prototype)
MyFilter.processFileContent = function(content, relPath, srcDir) {
  return 'content of filtered file'

  // You can return an array, when you need to create more than one file,
  // or to set special path of a file.
  return [
    {
      path: 'path/of/new/file',
      content: 'content'
    }
  ]
}

API

Filter(inputTree, [options])

Constructor.

inputTree

Type: Tree

options

Type: object

List of options

files

Type: array.<string>
Default: ['**']

Glob patterns for filtered files.

targetExtension

Type: string

New extension of filtered files.

changeFileName

Type: function(string) -> string

Function that is called for every file with its filename and should return new filename of the filtered file.
When this function is specified, option targetExtension doesn't work.

Filter.processFileContent(content, relPath, srcDir)

Returns: string|array.<object>

This method must be implemented in the inherited class. It processes content of each file from the inputTree that matches patterns and returns content of the new file.

If you need to create more than one file, or to set special path of a file, you can return an array of file objects with the following properties:

  • path – relative path of the new file.
  • content – content of the new file.

If you want to process a file asynchronously, you can return a promise.

content

Type: string

Content of source file.

relPath

Type: string

Relative path of source file.

srcDir

Type: string

Path of the inputTree. You can use it, when you need to read additional files from tree.

License

Public domain, see the LICENCE.md file.

Keywords

FAQs

Package last updated on 29 Jan 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc