Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gulp-mirror

popomore473MIT1.0.0

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

gulp, gulpplugin, stream, mirror, plugin

readme

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.

mirror([stream1, stream2 ..., streamN])

Sometimes the number of streams is variable, then we can pass to mirror an array of streams as unique argument.

LICENSE

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

changelog

1.0.0 / 2016-02-01

  • added array arguments

0.4.0 / 2015-02-15

  • fix: links and typo
  • chore: update badge
  • chore: add autod and upgrade deps
  • chore: add more node version in travis
  • doc: LICENSE typo #1
  • doc: update README #2
  • doc: add examples #2

0.3.1

upgrade dependencies

0.3.0

  • if mirror has no argument, it just returns a passthrough stream.
  • if mirror has only one argument, it will create another passthrough stream.

0.2.1

mirror should end after all stream are end

0.2.0

data should be cloned

0.1.1

keywords

0.1.0

First version