Closed cooolbasha closed 10 years ago
gulp-if is just a function that takes 2 (optionally 3) parameters: the condition, the truthy stream, and the falsey stream. Yours is coffeescript, but I'll reply in JavaScript just so the parenthesis are more obvious.
// something about for stylesheet and filename
var laz = lazypipe()
.pipe(concat(filename))
.pipe(rename({suffix:'.min'});
gulp.src(stylesheet)
.pipe(watch())
.pipe(minify())
.pipe(gulpif(Boolean(filename), laz())
lazypipe is from https://www.npmjs.org/package/lazypipe
I guess my question was not right..I wanted to call either concat or rename based on the boolean return ..but I was debugging the gulp file..it was calling concat even before the gulpif. it is not the problem of passing parameter...
tried to simplfy the code.
gulp.src path.stylesheetCSS
.pipe gulpif true,rename(suffix: '.min'),concat(filename)
.pipe gulp.dest path.styleSheets
still the concat is called even though the true is passed...I put a debugger on concat..and it tries to stop there
Ah, I see I misunderstood your intent. If condition is true, rename. If it's false, concat. Then you have the call setup correctly. Because the condition could be dependent on properties of the file, both pipes are initialized, but as it runs through each file, it determines if the vinyl file relates to the truthy or falsey condition. In your case, nothing goes to concat, but concat is still initialized.
I am using gulp-if to check on condition to execute a task. but that task takes a variable. how do I pass the variable since it is async. Here is some code.