-
-
Save TexRx/c10e2481fbcaab29bf88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var combine = require('stream-combiner'); | |
function lazypipe() { | |
var createPipeline = function(tasks) { | |
var build = function() { | |
return combine.apply(null, tasks.map(function(t) { | |
return t.task.apply(null, t.args); | |
})); | |
}; | |
build.pipe = function(task) { | |
if(!task) { | |
throw "Invalid call to lazypipe().pipe(): no task specified"; | |
} else if(typeof task !== 'function') { | |
throw "Invalid call to lazypipe().pipe(): task is not a function"; | |
} | |
return createPipeline(tasks.concat({ | |
task: task, | |
args: Array.prototype.slice.call(arguments, 1) | |
})); | |
} | |
return build; | |
}; | |
return createPipeline([]); | |
} | |
module.exports = lazypipe; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsHintTasks = lazypipe() | |
.pipe(jshint) | |
.pipe(jshint.reporter, 'jshint-stylish'); | |
// this is OK, because lazypipes are immutable now | |
var jsTasks = jsHintTasks | |
.pipe(gulp.dest, 'build/js'); | |
var cssTasks = lazypipe() | |
.pipe(recess, recessConfig) | |
.pipe(less) | |
.pipe(autoprefixer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment