🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

generate-target

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

generate-target

Plugin for automatically creating tasks from declarative `target` configurations. Works with generate, assemble, verb, or any other base application with plugin support.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

generate-target NPM version NPM downloads Build Status

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.

Keywords

boilerplate

FAQs

Package last updated on 19 Jul 2016

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