hparra / gulp-rename

Rename files easily
MIT License
692 stars 73 forks source link

toString on path in function #54

Closed alexander-akait closed 9 years ago

alexander-akait commented 9 years ago

Add function toString to object in function. toString must return original path.

.pipe(rename(function (path) {
    var originalPath = path.toString();
}))
shinnn commented 9 years ago

Is there any use case?

alexander-akait commented 9 years ago

@shinnn i use multimatch in function rename. From the time it can be changed logic parse path. Not too elegant to do so.

var originalPath = path.join(filePath.dirname, filePath.basename + filePath.extname);

So I think that this possibility should be implemented to hide the details of logic, and easy to get the full path

shinnn commented 9 years ago

In this case you don't need to use gulp-rename. You can use through2 directly.

.pipe(through2.obj(function(file, enc, cb) {
  var originalPath = file.path;
  // your awesome process
  cb(null, file);
}))
alexander-akait commented 9 years ago

@shinnn why? i need rename file and gulp-rename perfect for me