Stream helper functions for cascading configurable gulp recipes for gulp-chef.
$ npm install --save gulp-ccr-stream-helper
Initializes and returns an helper object with prerequisite()
and runTask()
method.
The name will show up in error message.
Check if runtime context fulfilled.
Context of the caller. Always pass this
here.
Does this task / stream processor support upstream, i.e. can be piped to? False if not. Throws if not fulfilled.
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.
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.
The context to call task.
The task to run.
var helper = require('gulp-ccr-stream-helper')('My Stream Processor');
module.exports = function () {
var gulp = this.gulp;
var tasks = this.tasks;
var context, stream, i;
helper.prerequisite(this, true, 2);
context = {
gulp: gulp,
config: {}
};
stream = this.upstream;
for (i = 0; i < tasks.length; ++i) {
context.upstream = stream;
stream = helper.runTask(context, tasks[i]);
}
return stream;
};
module.exports.type = 'stream';