Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Make a mirror of stream
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
test
.editorconfig
.gitignore
.jshintrc
.npmignore
.travis.yml
HISTORY.md
Makefile
README.md
index.js
package.json

README.md

gulp-mirror

Make a mirror of stream, it's useful that do different transform of the same stream.


NPM version Build Status Build Status NPM downloads

Install

$ npm install gulp-mirror

Usage

Real world example.

var gulp = require('gulp');
var concat = require('gulp-concat');
var mirror = require('gulp-mirror');
var rename = require('gulp-rename');

gulp.task('default', function() {
  return gulp.src('src/**/*.js')
  .pipe(concat('all.js'))
  .pipe(mirror(
    rename('browser.js'),
    rename('common.js'),
    rename('node.js')
  ))
  .pipe(gulp.dest('dist'));
});

Concat all js files in src directory, then rename it using mirror that will create three files which are the same.

API

mirror(stream1, stream2 ..., streamN)

Pass the input stream to all the mirrored stream with cloned File object. The mirrored stream also can be pipeline stream using multipipe, see example 2.

gulp.src(source)
.pipe(sharedStream1)
.pipe(mirror(
  stream1,
  stream2,
  ...
  streamN
))
.pipe(sharedStream2)
.pipe(gulp.dest(dest));

Stream flow

                        -->  stream1 --> 
                      /                   \
src --> sharedStream1    -->  stream2 --> 
                      \                     \ 
                          -->    ...   -->     sharedStream2 --> dest
                        \                    /  
                           -->  streamN  --> 

if mirror has only one argument, it will create another passthrough stream, just like gulp-clone, See example 3.

LICENSE

Copyright (c) 2015 popomore. Licensed under the MIT license.

Something went wrong with that request. Please try again.