Skip to content
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

Allowing for dynamic destinations by accepting functions as the path … #99

Closed
wants to merge 1 commit into from

Conversation

ktstowell
Copy link

One of my coworkers was trying to dump concatenated files into directories dynamically based on their origins. This PR attempts to cover that use case while maintaining existing functionality. This is what I added to the README:


Concat can also take a function for its first argument or as the value of path if using the object syntax.

function name(file) {
  return 'dest.js';
}

gulp.task('concat', function() {
  return gulp.src(['./scripts/**/*.js])
    .pipe(concat(name))
    .pipe(gulp.dest('./dist/'));
});

The function will be passed the current file from the stream. The most common use case for this is to output concatenated files into groupings based on their origination. The bottom line is that this allows you to add a destination dynamically.

To see an example, fork this repository and run the tests in ./spec.

…name.

See readme and PR notes for further elaboration.
@ktstowell
Copy link
Author

Closing because I suddenly feel weird about my tests being outside of the existing runner. Will open once I integrate.

@ktstowell ktstowell closed this Jul 9, 2015
@yocontra
Copy link
Member

yocontra commented Jul 9, 2015

This PR is doing a ton of stuff, can you outline what else is being added and split it up into multiple PRs?

@ktstowell
Copy link
Author

Sure - after integrating the tests I realized it was a sizable change with how concat has fundamentally worked so I created #100 to see if this would even be a change you all would be interested in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants