generate-target
v0.1.1
Published
Plugin for automatically creating tasks from declarative `target` configurations. Works with generate, assemble, verb, or any other base application with plugin support.
Downloads
10
Maintainers
Readme
generate-target
Plugin for automatically creating tasks from declarative target
configurations. Works with generate, assemble, verb, or any other base application with plugin support.
Usage
Can be used with any base application, including assemble, generate, and update.
var target = require('generate-target');
Example
var Base = require('base');
var targets = require('base-target');
var app = new Base({isApp: true});
app.use(targets());
// create a target
app.target('abc', {
src: 'templates/*.hbs',
dest: 'site',
});
// get a target
app.target('abc')
.generate({cwd: 'fo'}) // build the files in a target
.on('error', console.error)
.on('end', function() {
console.log('done!');
});
See the expand-target library for additional information and API documentation.
API
.targetSeries
Asynchronously generate files from a declarative target configuration.
Params
target
{Object}: Target configuration object.next
{Function}: Optional callback function. If not passed,.targetStream
will be called and a stream will be returned.
Example
var Target = require('target');
var target = new Target({
options: {cwd: 'source'},
src: ['content/*.md']
});
app.targetSeries(target, function(err) {
if (err) console.log(err);
});
.targetStream
Generate files from a declarative target configuration.
Params
target
{Object}: target configuration object.returns
{Stream}: returns a stream with all processed files.
Example
var Target = require('target');
var target = new Target({
options: {},
files: {
src: ['*'],
dest: 'foo'
}
});
app.targetStream(target)
.on('error', console.error)
.on('end', function() {
console.log('done!');
});
Tasks
If the instance has a task
method, a task is automatically created for each target.
Example
app.target('docs', {src: 'src/docs/*.md', dest: 'docs'});
app.target('site', {src: 'src/site/*.hbs', dest: 'site'});
app.build(['docs', 'site'], function(err) {
if (err) return console.log(err);
console.log('done!');
});
Disable auto-tasks
Pass options to the plugin to disable this feature.
app.use(targets({tasks: false}));
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running tests
Install dev dependencies:
$ npm install -d && npm test
Author
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on July 19, 2016.