gulp-community / gulp-concat

Streaming concat middleware for gulp
MIT License
792 stars 127 forks source link

Dynamic target-name resolution via function as argument. #100

Closed ktstowell closed 9 years ago

ktstowell commented 9 years ago

I've added some functionality on my fork (https://github.com/ktstowell/gulp-concat) that allows the user to pass in a function as the first argument (or as the value of path). The returned value would then be used as the target for file contents.

Running the test suite would further elaborate what I was trying to accomplish. Basically, with the given glob of: ['scripts/one/**/*.js', 'scripts/two/**/*.js', ''scripts/three/**/*.js'] to result in the contained files of each directory in a dedicated file of the user's choosing - in the case of the test: dist/one.js, dist/two.js, dist/three.js.

I want to submit a PR but in accommodating this new functionality, I have invalidated some tests and was looking for some guidance as to whether they are still meaningful.

(at 48e757a90687a8c5bca9d2945285ac0689aa7023 the last test of 4) should calculate relative path from cwd and path in arguments is failing. It does not seem to be affected by my changes)

So if someone could clone my forked repo and run the tests and check out the changes that would be great. If it sounds like something gulp-concat would be interested in I will open a PR.

Thanks!

yocontra commented 9 years ago

I feel like this could be solved easily with a meta stream tool instead of putting it into the lib. Branching based on filename is a very common use case and shouldn't be built into every single plugin. Have you tried using gulp-if for this?

.pipe(gif('a/b/**/*.js', concat('b.js'))
.pipe(gif('a/c/**/*.js', concat('c.js'))
// etc
ktstowell commented 9 years ago

Definitely achievable via gulp-if, which is how I have traditionally done it. The idea was to be able to handle JIT target names if the structure of the app is dynamic.

This is why I'm putting some feelers out there: to see if this has any philosophical alignment to the project.

yocontra commented 9 years ago

I think gulp-if or other stream meta-tools are the way to handle this since it is such a common thing you would do with other plugins as well

ktstowell commented 9 years ago

That's fair. Thanks for the involvement and feedback!