gulp-ccr-stream-helper
Stream helper functions for cascading configurable gulp recipes for gulp-chef.
Install
$ npm install --save gulp-ccr-stream-helper
API
helper(name): object
Initializes and returns an helper object with prerequisite()
and runTask()
method.
name
The name will show up in error message.
helper.prerequisite(context, upstream, minTasks)
Check if runtime context fulfilled.
context: object
Context of the caller. Always pass this
here.
upstream: boolean
Does this task / stream processor support upstream, i.e. can be piped to? False if not. Throws if not fulfilled.
minTasks: integer
Optional. How many sub task must be provided at minimum? Default to 1. Throws if not fulfilled.
Number of 0 means this stream processor can be used as a normal task.
helper.runTask(context, task): stream
Call task with given context and checks:
- Does the task return a stream? Throws if not.
- Does the task try to call the "
done()
" callback? Throws if it does.
context
The context to call task.
task
The task to run.
Example
var helper = 'My Stream Processor';module {var gulp = thisgulp;var tasks = thistasks;var context stream i;helper;context =gulp: gulpconfig: {};stream = thisupstream;for i = 0; i < taskslength; ++icontextupstream = stream;stream = helper;return stream;};moduleexportstype = 'stream';