Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor behavior when path and history are provided #95

Closed
phated opened this issue Jul 28, 2016 · 9 comments
Closed

Constructor behavior when path and history are provided #95

phated opened this issue Jul 28, 2016 · 9 comments

Comments

@phated
Copy link
Member

phated commented Jul 28, 2016

I noticed in the PR (#94) that history is reset if a vinyl object is constructed with both a path and history property; e.g. new Vinyl({ path: '/pets/cat', history: ['/pets/dog'] }) has ['/pets/cat'] as the history.

Shouldn't the constructor append the new path to the history if we specify both? In my example, it would result in ['/pets/dog', '/pets/cat'] as the history on the new object.

/cc @contra

@phated
Copy link
Member Author

phated commented Aug 16, 2016

@contra @darsain @Marak @erikkemperman any thoughts on this?

@darsain
Copy link
Contributor

darsain commented Aug 17, 2016

I'm all for appending to history. Makes sense.

@erikkemperman
Copy link
Member

It does sound very reasonable to append... But I notice that current behaviour does seem deliberate:

Path history. Has no effect if options.path is passed.

https://github.com/gulpjs/vinyl/blob/master/README.md#optionshistory

@phated
Copy link
Member Author

phated commented Aug 17, 2016

@erikkemperman it would be a breaking change to be queued up for the 2.0 release. I can't see a reason for it to have no effect.

@phated
Copy link
Member Author

phated commented Aug 17, 2016

Side notes: It looks like the original implementation in #24 had that behavior and then an issue for history cloning was noted in #35 (with the fix in d220c85). None of those mentioned or took into account what I am mentioning. But the docs for the feature were written in #48 which were just based on the behavior as implemented, as opposed to a conscious decision.

@erikkemperman
Copy link
Member

Agreed, I think it makes a lot of sense. Just wanted to point out that the way it is now looked deliberate.

@phated
Copy link
Member Author

phated commented Aug 17, 2016

@erikkemperman understandable, that's why I did the digging to see if it was. It doesn't seem to be. Maybe the path needs to be compared to the last history item before being set. If it is the same, don't add to history.

@erikkemperman
Copy link
Member

The setter for path already compares to the last element in history, so that would certainly be consistent.
https://github.com/gulpjs/vinyl/blob/master/index.js#L264

@phated
Copy link
Member Author

phated commented Aug 17, 2016

Cool. I think there's a way to leverage that behavior in these changes then.

@phated phated closed this as completed in 272f175 Sep 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants