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

Allow to set file stats on dest() #96

Closed
piranna opened this issue Sep 20, 2015 · 8 comments
Closed

Allow to set file stats on dest() #96

piranna opened this issue Sep 20, 2015 · 8 comments

Comments

@piranna
Copy link
Contributor

piranna commented Sep 20, 2015

vinyl headers has support for the file stats, but dest() is not preserving them. opt field could accept a stat field and use it, I'm mostly interested on mtime since download can't be able to preserve it, and source code tarballs fail. This can be done with the fs.utimes() function.

@yocontra
Copy link
Member

Can you clarify a bit more? FYI you can do this in a plugin prior to dest - just modify file.stats

@piranna
Copy link
Contributor Author

piranna commented Sep 21, 2015

Thanks for the advice about the plugin ;-) What I'm asking about is that at https://github.com/contra/vinyl-fs/blob/5b056f66c476ff32687c172d5fe79eaf47b2e80e/lib/dest/writeContents/writeBuffer.js#L6-L11 and https://github.com/contra/vinyl-fs/blob/5b056f66c476ff32687c172d5fe79eaf47b2e80e/lib/dest/writeContents/writeStream.js#L7-L12 file is created with current mtime instead of the one defined on file.stats. fs.writeFile() and fs.createWriteStream() don't allow to set the stats or the time on their arguments, but this can be set with the fs.utimes() function, just call it after the file is created.

@yocontra
Copy link
Member

@piranna Interesting... could you explain your use case a bit more? You might want to try using symlinks instead of having gulp copy the files over - use gulp.symlink instead of gulp.dest

@phated
Copy link
Member

phated commented Sep 21, 2015

@contra the referenced download issue has more reasoning why they need the mtime from stats. It seems that some files can't be unzipped if their created time is different than the original tar

@piranna
Copy link
Contributor Author

piranna commented Sep 21, 2015

yes, @phated is (almost) true, some times source code tarballs can't be compiled if their time is different of the original ones since make think they have been changed, that's why it's needed to preserve the original time. vynil headers use already the current time by default on the stat entry, so it's ok to set them always after the files are created.

@piranna
Copy link
Contributor Author

piranna commented Oct 14, 2015

I've created a pull-request to fix this.

@phated
Copy link
Member

phated commented Oct 16, 2015

Published this change as 2.2.0

@phated phated closed this as completed Oct 16, 2015
@piranna
Copy link
Contributor Author

piranna commented Oct 16, 2015

Thank you :-)

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