hparra / gulp-rename

Rename files easily
MIT License
692 stars 73 forks source link

Pass file object rename function #19

Closed retrofox closed 9 years ago

retrofox commented 10 years ago

For some particular situations I've needed that work watching the file stream. For instance when the src parameter is an array.


gulp
  .src(['/scripts/main.js', 'styles/main.styl'])
  .rename(function(path, file){
    // work like always but now file stream is here
  });

Best!

nfroidure commented 10 years ago

Can be relevant for changing the cwd propety of vinyl files

retrofox commented 10 years ago

then don't change any file property. I use file.path to know the real path for each file.

npup commented 10 years ago

Heh! I just modified my local files to do this, and then prepared to make a PR when I saw it was already in the oven (and ready for merge afaikt). Go for it :)

izaakschroeder commented 9 years ago

:+1: can we get this merged?

SimenB commented 9 years ago

:+1:

shinnn commented 9 years ago

@retrofox

Could you show us more detailed use case?

I'm afraid that this API might be used outside the use of rename plugin.

shinnn commented 9 years ago

Closing this PR since we can directly use through2 in this case.

var gulp = require('gulp');
var through = require('through2');

gulp.src('src/*.js')
  .pipe(through.obj(function(file, enc, cb) {
    // process
  }));
bard commented 9 years ago

Perhaps there are other reasons that aren't mentioned here, but rejecting this based on the fact that it can be done with through2 seems moot. We could directly use through2 in the .pipe(rename(function(path) {...})) case, too, yet the functionality is there.