Skip to content

Instantly share code, notes, and snippets.

@alexeyraspopov
Created February 2, 2014 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexeyraspopov/8769337 to your computer and use it in GitHub Desktop.
Save alexeyraspopov/8769337 to your computer and use it in GitHub Desktop.
Simple way to write your pipes

Simple way to write your pipes

When I write gulpfile I don't like a lot of pipe calls especially when I have a lot of tasks to do. Thats why I use small function to create pipeline from array.

var toPipe = require('gulp-pipe');

gulp.task('js', function(){
  return toPipe([
    gulp.src('some/src'),
    jshint(),
    complexity(),
    karmaTests(),
    coverage(),
    uglify(),
    gulp.dest('some/dest')
  ]);
});

This function works with streams, so you can use it anywhere you want.

module.exports = function(array){
return array.reduce(function(a, b){
return a.pipe(b);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment