gulpjs / gulp-util

[deprecated] - See https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
MIT License
830 stars 104 forks source link

Using "extname" and other shorthand getters in ".clone()" opts. #122

Closed jamen closed 8 years ago

jamen commented 8 years ago

Would be handy for quickly changing extension in plugins that compile, or in any case where you just need to change the extension:

const html = file.clone({ extname: '.html' });
html.contents = foobar.render(...);
phated commented 8 years ago

This doesn't belong in the gulp-util repo, as it is related to vinyl; however, I don't think the clone API would be suitable to overload for this feature. If you want to open a different issue on https://github.com/gulpjs/vinyl that suggests a new API, we can discuss there.

jamen commented 8 years ago

My bad, I opened here because I was using gutil.replaceExtension(...) and it was pretty late IIRC.

phated commented 8 years ago

@jamen I'm not sure what version of vinyl added the feature (and it might not be shipping with gulp 3.x), but you can use file.extension = '.html' now and it has a setter that handles what replaceExtension used to