Closed jgable closed 10 years ago
file.clone() exists for this reason - why not use it? It clones history
Same problem exists with your file.clone()
.
https://github.com/wearefractal/vinyl/blob/master/index.js#L67
https://github.com/wearefractal/vinyl/blob/master/index.js#L160
History (and thus the path var) gets cloned fine - there are tests for it in the clone tests
This issue is not about cloning, it's about re-hydrating a cloned File from after serializing to disk.
After cloning, yes, the history is preserved, but if I want to create a new file and all I have is a file's enumerable properties from a JSON.stringify
stored to disk I have to have special cases to pluck off the last history item from the files properties. This is dirty because I have to know about the internal workings of the File class and how it calculates that path property.
Published as 0.4.3
It looks like wearefractal/vinyl#24 significantly changed the way
path
is stored on a File instance. Ever since this change, you can't re-"hydrate" a File object from a clone because the clone result doesn't include the path property, but the File constructor requires a path and won't respect the passed in history.I'm left with a sort of hacky
I think you should check for the passed in history and use it if present, otherwise fall back to your current
this.history = file.path ? [file.path] : [];
line.