GithubHelp home page GithubHelp logo

isabella232 / broccoli-writer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from broccolijs/broccoli-writer

0.0 0.0 0.0 141 KB

Base class for Broccoli plugins that write an output tree

License: MIT License

JavaScript 100.00%

broccoli-writer's Introduction

broccoli-writer

Deprecated in favor of broccoli-plugin.

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 install --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, ...)

broccoli-writer's People

Contributors

joliss avatar quaertym avatar rwjblue avatar xtian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.