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

Set atime, mtime and ctime from contents accessors #75

Merged
merged 3 commits into from
Jan 15, 2016

Conversation

erikkemperman
Copy link
Member

As discussed in #1461, I think this covers the simple case.

Note: I had to adjust tests in vinyl-fs to get them to pass against vinyl with this patch, will submit a PR for that as well.

Edit: and here it is.

@@ -149,12 +149,24 @@ File.isVinyl = function(file) {
// Or stuff with extra logic
Object.defineProperty(File.prototype, 'contents', {
get: function() {
if (this.stat && this.stat.atime) {
this.stat.atime.setTime(Date.now());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why setTime instead of an assignment? We aren't sure if the value is actually a date object, since a vinyl object could be constructed with an int for timestamp (and it should work fine, I think)

@erikkemperman
Copy link
Member Author

Added some code to the constructor which transforms integer into dates. And accompanying test.

Better to use setTime in the critical path, I think, rather than constructing new Dates over and over.

If we're worried that, post File constructor, people might do file.stat.atime = <int> then I guess we could go ahead with something like better-stats after all, which would then have setters to coerce into Dates?

@phated
Copy link
Member

phated commented Jan 14, 2016

Yeah, I think that is going to be the final result, but I am good with something in the interim. Thanks.

phated added a commit that referenced this pull request Jan 15, 2016
Set atime, mtime and ctime from contents accessors
@phated phated merged commit 3a80173 into gulpjs:master Jan 15, 2016
@phated
Copy link
Member

phated commented Jan 15, 2016

@erikkemperman I was thinking this could be added as a feature, but it might be considered breaking for anyone that was relying on timestamps not changing. Do you think this warrants a major bump?

@erikkemperman
Copy link
Member Author

@phated Actually I was about to question if the set of stats-related PRs, as it stands, doesn't need a little more thought.

Some things now strike me as more a consequence of the particular order in which issues were raised than systematic -- and documented -- analysis of what should actually happen in various cases.

@erikkemperman
Copy link
Member Author

@phated I believe the vinyl patch you just merged here is pretty much ok, and then I suppose the vinyl-fs patch here should probably also be merged to keep its tests happy.

But the interaction with src and dest, which is the PR by @piranna and myself, somehow feels too ad-hoc. I would be uncomfortable having that in master just yet...

@phated
Copy link
Member

phated commented Jan 15, 2016

@erikkemperman I will avoid versioning it until we have everything nailed down in how it is supposed to work. I am running stuff through some test repos along with the unit tests.

@phated
Copy link
Member

phated commented Jan 18, 2016

@erikkemperman I rebased this stuff out. Do you want to open it again for a lengthier discussion?

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

Successfully merging this pull request may close these issues.

2 participants