gulp-pipe

1.0.4 • Public • Published

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);});

Source:

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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i gulp-pipe

      Weekly Downloads

      64

      Version

      1.0.4

      License

      MIT

      Last publish

      Collaborators

      • blakelapierre