Socket
Socket
Sign inDemoInstall

broccoli-writer

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-writer

Helper base class for Broccoli plugins that write output files


Version published
Weekly downloads
14K
decreased by-61.23%
Maintainers
1
Weekly downloads
 
Created
Source

broccoli-writer

Base class for Broccoli plugins that write an output tree. Most plugins fall into this category (the exception being plugins that just point at an existing directory on the file system, like broccoli-bower), so they will be implemented either using this base class or using a derived, more specific base class.

This base class's main purpose is to create and clean up the temporary output directory for you.

Installation

npm --save broccoli-writer

Usage

Write your plugin like so:

var Writer = require('broccoli-writer');

module.exports = MyCompiler;
MyCompiler.prototype = Object.create(Writer.prototype);
MyCompiler.prototype.constructor = MyCompiler;
function MyCompiler (arg1, arg2, ...) {
  if (!(this instanceof MyCompiler)) return new MyCompiler(arg1, arg2, ...);
  ...
};

MyCompiler.prototype.write = function (readTree, destDir) {
  ...
};

Inside MyCompiler.prototype.write, readTree is supplied by Broccoli -- call readTree(someInputTree) to read another tree. destDir is the path to a newly-created temporary directory created by the Writer base class. Place all the output files you wish to generate in this directory.

If you want to do something asynchronous, return a promise that resolves when you are done.

In the MyCompiler constructor, you don't need to call the Writer base class constructor.

Your plugin can be used in Brocfile.js like so:

var compileSomething = require('broccoli-my-compiler');

var outputTree = compileSomething(arg1, arg2, ...)

Keywords

FAQs

Package last updated on 02 Apr 2014

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