0.7.0 • Published 3 years ago

pipemaker v0.7.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Pipemaker

Powerful chaining of pre- and post-processors, with dynamic dependency downloading.

Installation

$ npm install pipemaker

Examples

var pipemaker = new Pipemaker();

// Simple pipelines (extension, name)
pipemaker.addPipeline("jade");
pipemaker.addPipeline("coffee");
pipemaker.addPipeline("js", "dust");

// Chained pipelines (extension, chain)
pipemaker.addPipeline("css", "css>clean-css");
pipemaker.addPipeline("js", "javascript>uglify-js");
pipemaker.addPipeline("jbs", "jade>handlebars");

function next(err, compiled) { console.log(compiled); }

// Compile
pipemaker.compile("coffee", "console.log 'Hello'", next);
pipemaker.compile("handlebars", "Hello {{ name }}", { name : "Donald" }, next);
pipemaker.compileFile("./path-to/file.coffee", next);

API

PipemakerPipemaker .addPipeline(ext, [chain])function .compile(ext, str, [options], next) .compileBlock(lines, lineNo, [options], next) .compileFile(filename, [options], next) .compileWildcard(str, [options], next) .createPipeline(chain)function .getPipeline(chain)function .hasPipeline(ext)Boolean .removePipeline(ext)

Pipemaker ⇒ Pipemaker

Constructor for Pipemaker class. Automatically installs packages by default.

Returns: Pipemaker - Instance of class.

ParamTypeDescription
mappingsObjectKeys correspond to extensions, values to pipeline names.
optionsObjectInstall directory dir, and whether to fetch if missing.

Example

var pipemaker = new Pipemaker({ dir : process.cwd() });

pipemaker.compile(ext, str, options, next)

compiles a string using pipeline associated with ext

ParamTypeDefaultDescription
extStringThe extension associated with string (e.g. "coffee").
strStringThe string to be compiled.
optionsObject{}Options to be passed to rendering pipeline.
nextfunctionCallback of type fn(err, compiled).

Example

pipemaker.compile("coffee", "console.log 'Hello'", function(err, compiled) {
    console.log(compiled);
    // => console.log('Hello');
  });

pipemaker.compileFile(filename, options, next)

compiles a file using pipeline associated with file's extension

ParamTypeDefaultDescription
filenameStringName of file.
optionsObject{}Options to be passed to rendering pipeline.
nextfunctionCallback of type fn(err, compiled).

Example

pipemaker.compileFile("app.coffee", function(err, compiled) {
    // Compiled version of app.coffee
  });

pipemaker.compileWildcard(str, options, next)

Compiles a wildcard string.

ParamTypeDefaultDescription
strStringThe string to be compiled.
optionsObject{}Options to be passed to rendering pipeline.
nextfunctionCallback of type fn(err, compiled).

pipemaker.compileBlock(lines, lineNo, options, next)

Recursively compiles a wildcard block.

ParamTypeDefaultDescription
linesArrayThe lines to be compiled
lineNoNumberThe line number to start with
optionsObject{}Options to be passed to rendering pipeline
nextfunctionCallback of type fn(err, compiled, numberOfLinesProcessed)

pipemaker.createPipeline(chain) ⇒ function

Returns a compilation function based on input chain.

Returns: function - Compilation function fn(str, options, next).

ParamTypeDescription
chainStringString containing names of pipelines to use.

Example

pipemaker.createPipeline("jade");
  pipemaker.createPipeline("jade>handlebars");
  pipemaker.createPipeline("js>uglify-js");

pipemaker.getPipeline(chain) ⇒ function

Gets an pipeline based on chain, creating pipeline if necessary.

Returns: function - Compilation function fn(str, options, next).

ParamTypeDescription
chainStringChain of pipelines.

Example

pipemaker.getPipeline("jade>handlebars");

pipemaker.addPipeline(ext, chain) ⇒ function

Adds an pipeline for an extension, creating pipeline if necessary.

Returns: function - Compilation function fn(str, options, next).

ParamTypeDescription
extStringFile extension to be associated with pipeline.
chainStringOptional chain for creating pipeline.

pipemaker.removePipeline(ext)

Removes an pipeline by extension.

ParamTypeDescription
extStringFile extension to for removal.

pipemaker.hasPipeline(ext) ⇒ Boolean

Determines if an pipeline currently exists for an extension.

Returns: Boolean - Whether pipeline exists.

ParamTypeDescription
extStringFile extension to check.

License

MIT

0.7.0

3 years ago

0.6.0

7 years ago

0.5.0

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.8

8 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago