Index: tools/migration/lib/src/editable_status_file.dart |
diff --git a/tools/migration/lib/src/editable_status_file.dart b/tools/migration/lib/src/editable_status_file.dart |
index 7a3795266da73de500e6aa935e8105b866912f84..ad5c04537921af7174646d60284efe537ef0e28b 100644 |
--- a/tools/migration/lib/src/editable_status_file.dart |
+++ b/tools/migration/lib/src/editable_status_file.dart |
@@ -24,7 +24,11 @@ class EditableStatusFile { |
StatusFile _statusFile; |
StatusFile get statusFile { |
if (_statusFile == null) { |
- _statusFile = new StatusFile.read(path); |
+ if (new File(path).existsSync()) { |
+ _statusFile = new StatusFile.read(path); |
+ } else { |
+ _statusFile = new StatusFile(path); |
+ } |
} |
return _statusFile; |
@@ -94,11 +98,27 @@ class EditableStatusFile { |
void _ensureLines() { |
jcollins
2017/08/04 16:55:56
optional: replace this and _lines with a getter fo
Bob Nystrom
2017/08/04 17:33:01
Good idea, done.
|
if (_lines == null) { |
- _lines = new File(path).readAsLinesSync(); |
+ var file = new File(path); |
+ if (file.existsSync()) { |
+ _lines = file.readAsLinesSync(); |
+ } else { |
+ _lines = [ |
+ "# Copyright (c) 2017, the Dart project authors. Please see the " |
+ "AUTHORS file", |
+ "# for details. All rights reserved. Use of this source code is " |
+ "governed by a", |
+ "# BSD-style license that can be found in the LICENSE file." |
+ ]; |
+ } |
} |
} |
void _save() { |
+ if (dryRun) { |
+ print("Save ${bold(path)}"); |
+ return; |
+ } |
+ |
new File(path).writeAsStringSync(_lines.join("\n") + "\n"); |
// It needs to be reparsed now since the lines have changed. |