hparra / gulp-rename

Rename files easily
MIT License
692 stars 73 forks source link

Access file object from function. #62

Closed camilleterol closed 8 years ago

camilleterol commented 8 years ago

It's more a feature request than an issue. I wonder if some people are interested in this function. For a particular project, (a file-based, static blog "engine"), I'd like to get data from the front matter, and rename my file accordingly (i.e. move a file to date folder/tree - yyyy/mm/dd/my-file.md) My data is fed through the file object down the stream.

It'd be great if we could have a second parameter in the function passed to rename, where we could have the file object, and gain access to it. and do something like this:

.pipe(plugins.rename(function(path, file) {
    path.basedir = file.frontMatter.date.getYear();
}))
shinnn commented 8 years ago

https://github.com/hparra/gulp-rename/pull/52#issuecomment-120421471