1 | # gulp-streamify
|
2 | > Wrap old [Gulp](http://gulpjs.com/) plugins to support streams.
|
3 |
|
4 | [![NPM version](https://badge.fury.io/js/gulp-streamify.svg)](https://npmjs.org/package/gulp-streamify) [![Build status](https://secure.travis-ci.org/nfroidure/gulp-streamify.svg)](https://travis-ci.org/nfroidure/gulp-streamify) [![Dependency Status](https://david-dm.org/nfroidure/gulp-streamify.svg)](https://david-dm.org/nfroidure/gulp-streamify) [![devDependency Status](https://david-dm.org/nfroidure/gulp-streamify/dev-status.svg)](https://david-dm.org/nfroidure/gulp-streamify#info=devDependencies) [![Coverage Status](https://coveralls.io/repos/nfroidure/gulp-streamify/badge.svg?branch=master)](https://coveralls.io/r/nfroidure/gulp-streamify?branch=master)
|
5 |
|
6 | It is pretty annoying when Gulp plugins doesn't support streams. This plugin
|
7 | allows you to wrap them in order to use the stream mode anyway. It is pretty
|
8 | useful when you want to take advantage of streams on part of your pipelines.
|
9 |
|
10 | *Note to gulp plugin developpers*: This plugin should not discourage you to
|
11 | support streams in your own plugins. I made this plug-in to avoid beeing
|
12 | stucked with a bad plugin. If your underlying library support streams, please,
|
13 | use it! Even if it doesn't, use
|
14 | [BufferStreams](https://npmjs.org/package/bufferstreams)
|
15 | in your plugins to support streams at the plugin level (it won't block files
|
16 | to buffer their contents like this library has to do to work). Here is a
|
17 | [sample of bufferstreams usage](https://github.com/nfroidure/gulp-ttf2eot/blob/master/src/index.js#L73)
|
18 | in Gulp plugins.
|
19 |
|
20 | ## Usage
|
21 |
|
22 | First, install `gulp-streamify` as a development dependency:
|
23 |
|
24 | ```shell
|
25 | npm install --save-dev gulp-streamify
|
26 | ```
|
27 |
|
28 | Then, add it to your `gulpfile.js` and wrap all that shit:
|
29 |
|
30 | ```javascript
|
31 | var streamify = require('gulp-streamify');
|
32 | var noStreamPlugin = require('gulp-no-stream');
|
33 |
|
34 | gulp.task('stream', function(){
|
35 | gulp.src(['**/*'])
|
36 | .pipe( streamify( noStreamPlugin() ) )
|
37 | .pipe(gulp.dest('/tmp'));
|
38 | });
|
39 | ```
|
40 |
|
41 | If you have several plugins to wrap together, prefer calling `gulp-streamify`
|
42 | once thanks to the function form of the `gulp-streamify` constructor:
|
43 | ```javascript
|
44 | var gStreamify = require('gulp-streamify');
|
45 | var noStreamPlugin = require('gulp-no-stream');
|
46 | var noStreamPlugin2 = require('gulp-no-stream2');
|
47 | var plexer = require('plexer');
|
48 |
|
49 | gulp.task('stream', function(){
|
50 | gulp.src(['**/*'])
|
51 | .pipe(streamify(function() {
|
52 | var instream = noStreamPlugin();
|
53 | var outstream = noStreamPlugin2();
|
54 | instream
|
55 | .pipe(anyOtherStream)
|
56 | .pipe(outStream);
|
57 | return plexer(instream, outstream);
|
58 | }))
|
59 | .pipe(gulp.dest('/tmp'));
|
60 | });
|
61 | ```
|
62 |
|
63 | ## API
|
64 |
|
65 | ### stream : streamify(toBeWrap)
|
66 |
|
67 | Take a stream or a function returning a stream to wrap an return a stream mode
|
68 | compatible stream.
|
69 |
|
70 | ## Contributing / Issues
|
71 |
|
72 | You may want to contribute to this project, pull requests are welcome if you
|
73 | accept to publish under the MIT licence.
|