-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support array of conditions #37
Comments
+1 for the feature |
+1 |
I like the idea of an array of match conditions. Should we hard-code that all must match? Or any? (e.g. |
+1 |
plus one more here! |
@robrich hardcoding would be the "easy" way to go, but implementing one or the other would likely cause people to want the other one as well, and once they have both, then a way to specify chains of conditionals. If you give a mouse a cookie... Without creating a complex builder system, you could probably do If we wanted to get wild, you might be able to go with an object structure, that allowed for multiple nested conditionals, something like the following: var crazy = {
AND: [ {
OR:[ boolean_conditional, bool_function(), ETC ]
},
boolean_conditional,
"string_matcher*.js"
]
}
gif(crazy, minify()) but that's crazy and needlessly complex. |
... and this "give a mouse a cookie" is part of my hesitation here. It almost sounds like you should pass in a function, I hand off the arguments you need to run your crazy, and you hand me back a boolean answer ... which by the way is the work-around the original author uses. :D I'm thinking if we take an opinion, |
For the record. I no longer need this.
|
Perhaps then the "easiest" solution then, would be to provide examples of multi-conditional external functions, added as a pattern in the README? If the file object is always available, it is less work for @robrich to "implement". Otherwise, while I don't know enough about what is kosher in terms of the multi file glob pattern, but mixing booleans with strings in an array, and checking them internally, sounds like an anti-pattern. Similarly, using an array of strings, conditionals, and/or string arrays (for the glob array), leaves you with nested arrays, and the likelihood of people accidentally assuming the array is flat, even if that inherently gets you an "or" pattern with anything in a sub array (assuming the sub array is a glob array and not mixed.) Quite the rabbit hole! |
Bump.
Is there a better solution for this? Also, it there a way to do this in one line? (match one glob OR the other)
I really miss the good old || and &&. |
@Trost123: in your first example, you could replace it with a function. I think what you've got isn't bad though. In your second example, pass in this: |
Thanks, that helps! Could you also help me with function soultion? |
that's the correct way to do it. Do you have a gist or pastebin we can review? |
Nevermind, I found the mistake (in my code). |
:D Problem solved. |
You might wanna fix your previous advice though: |
old issue, still open, my workaround on it is using vinyl directly:
can be extended to parse |
One currently has multiple options to support multiple conditions with
gulp-if
:But all of these (and more involving
lazypipe
), distract from the goal of this simple problem: matching a boolean condition with a glob condition.I propose something similar to the following to allow multiple conditions without nesting
gulp-if
instances:I don't believe the above will work as is because it conflicts with the multiple glob support in
gulp-match
, but it's the general idea of what i've got.The text was updated successfully, but these errors were encountered: