-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
rewrite file only when file data changed #613
rewrite file only when file data changed #613
Conversation
Good start, thanks! Now make it pass tests and also implement it python. |
ok. soon |
done test seems failed on
run the cli directly is ok, file created in |
No, the problem is the test expects even unchanged files to be written out... |
logToStdout('beautified ' + path.relative(process.cwd(), outfile), config); | ||
} catch (ex) { | ||
onOutputError(ex); | ||
if (code !== pretty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the problem. You can't just not write the code if it is the same. You need to check (around line 267) if the input and output path are the same. If so, you can check here if the input and output code is unchanged and not change that file. If the input path is empty, output path is empty (for piping cases), or if the input path differs from the output path you still have to write the output, even if it is unchanged.
rewrite file only when file data changed
Cool. We don't have a test to show that unchanged files are not written, but I can do that. And all the tests pass. Thanks! |
😄 |
The new tests seem to be OSX-specific, touch -A does not work with touch from GNU coreutils (Linux). |
@blino - please open a new issue, and if you are willing to contribute a fix that would be even better! |
also fix #597