blakelapierre / gulp-pipe

Expose your flows without laying so much `.pipe()`.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gulp-pipe

Expose your flows without laying so much .pipe()

Get rid of needless boilerplate noise and just focus on the stuff that changes.

Turn this (195 non-space characters):

return gulp.src(paths.scripts)
           .pipe(sourcemaps.init())
           .pipe(to5())
           .pipe(concat('index.js'))
           .pipe(sourcemaps.write('.'))
           .pipe(gulp.dest(paths.dist))
           .on('error', function(e) { console.log(e); });

Into this (175 non-space characters):

return pipe([
        gulp.src(paths.scripts)
        ,sourcemaps.init()
        ,to5()
        ,concat('index.js')
        ,sourcemaps.write('.')
        ,gulp.dest(paths.dist)
       ])
       .on('error', function(e) { console.log(e); });

Or this:

return pipe(gulp.src(paths.scripts),
            [
              sourcemaps.init(),
              to5(),
              concat('index.js'),
              sourcemaps.write('.'),
              gulp.dest(paths.dist)
            ])
            .on('error', function(e) {console.log(e);});
module.exports = function pipe(stream, tubes) {
  tubes = tubes || stream.slice(1);
  return tubes.reduce(function(stream, tube) { return stream.pipe(tube); }, Array.isArray(stream) ? stream[0] : stream);
};

Installation

npm install --save gulp-pipe

Under consideration

  1. Investigate flows for allowing inline .on, as in this example.

Notes

  1. This library is not specific to, nor has dependencies on, gulp. It will work for any Streams, however it was created to simplify my gulpfile.js's

About

Expose your flows without laying so much `.pipe()`.


Languages

Language:JavaScript 100.0%