Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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