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

Unified Diff: tools/migration/lib/src/editable_status_file.dart

Issue 2994573002: Handle migration status entries into split up status files. (Closed)
Patch Set: Created 3 years, 4 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
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.

Powered by Google App Engine
This is Rietveld 408576698