Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: lib/src/io.dart

Issue 850953004: Don't touch files whose contents do not change. Fix #127. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Update changelog. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | test/io_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/io.dart
diff --git a/lib/src/io.dart b/lib/src/io.dart
index 579ed1b2db25286d7d042c1034dfc2ee1671ea7d..e1910332a83d7354ec8cceceac4ce814491fd592 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -38,10 +38,15 @@ void processFile(File file, {String label, bool overwrite, int pageWidth}) {
var formatter = new DartFormatter(pageWidth: pageWidth);
try {
- var output = formatter.format(file.readAsStringSync(), uri: file.path);
+ var source = file.readAsStringSync();
+ var output = formatter.format(source, uri: file.path);
if (overwrite) {
- file.writeAsStringSync(output);
- print("Formatted $label");
+ if (source != output) {
+ file.writeAsStringSync(output);
+ print("Formatted $label");
+ } else {
+ print("Unchanged $label");
+ }
} else {
// Don't add an extra newline.
stdout.write(output);
« no previous file with comments | « CHANGELOG.md ('k') | test/io_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698