Document/implement setting arbitrary keys on Vinyl objects
strugee opened this issue · 5 comments
Vinyl objects should have some way of setting arbitrary data keys in addition to the builtin ones, like path
, stem
, etc. This would be incredibly useful in certain cases: for example, the ability to parse out YAML Front Matter into a Vinyl object that could then be consumed by downstream Gulp plugins would be super powerful.
I feel like there should be some way to do this already, but I've tried a bunch of different ways with no luck. So, this process should be documented or, if it's not actually possible, it should be implemented.
Vinyl objects are just JavaScript objects. You can tack properties onto instances, change the prototype, inherit from them. We don't plan to document features of JavaScript on this library. The frontmatter thing you describe is already done by https://www.npmjs.com/package/gulp-data - maybe you can better understand this by looking at the source.
To answer more concretely: file.attributeName = value;
is how you do this
@phated that's what I thought, but then when the object gets sent down a stream, the properties don't seem to come along for the ride. I'll take a look at the linked package to see if I can figure it out from that, thanks.
FWIW, I asked a question on Stack Overflow about this.