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

Add option to skip write of unchanged file #94

Open
rwe opened this issue Dec 4, 2017 · 1 comment
Open

Add option to skip write of unchanged file #94

rwe opened this issue Dec 4, 2017 · 1 comment

Comments

@rwe
Copy link

rwe commented Dec 4, 2017

Stumbling across this in a Yeoman generator in repos with Makefiles. When generating files that already exist, even if the generated contents are identical to those on disk, they are still unconditionally written with updated timestamps.

I can see use cases for wanting that timestamp updated anyway, so I don't strongly suggest unconditionally skipping this as a default. Perhaps something like forceWrite: false should be an option that can be passed to .copy/.copyTpl/etc.?

.copy calls .write here:

this.write(to, contents, file.stat);

File state unconditionally set as modified here:

file.state = 'modified';

Which is checked here before writing:

if (file.state === 'modified') {
write(file);

@SBoudrias
Copy link
Owner

I think it'd make sense to just skip the write if the content is the same; I don't quite see the value of updating the file timestamp. Seems you already dug into the relevant code, would you be willing to send a PR?

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

2 participants