robrich / gulp-if

Conditionally run a task
MIT License
655 stars 26 forks source link

Gulp switch? #26

Closed reverofevil closed 10 years ago

reverofevil commented 10 years ago

What if I would like a switch?

robrich commented 10 years ago

Make the condition a function that takes in the file and put the switch in your function.

reverofevil commented 10 years ago

According to README.md, that function should return boolean, not a stream. How is it supposed to combine outputs of child streams?

robrich commented 10 years ago

The second and optionally the third arguments are your streams. The boolean condition tells ternary-stream (ultimately fork-stream) which stream should receive each file. The results of your "if" and "else" streams are then combined back into an output stream using event-stream.merge. duplexer2 then combines the input and output streams into a single stream that users consume. See https://github.com/robrich/ternary-stream/blob/master/index.jsand https://github.com/robrich/ternary-stream/blob/master/img/ternary.svg

popomore commented 10 years ago

Maybe you can try this https://github.com/popomore/stream-switch