OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "dart:io"; | 5 import "dart:io"; |
6 import "package:args/args.dart"; | 6 import "package:args/args.dart"; |
7 | 7 |
8 bool cleanBuild; | 8 bool cleanBuild; |
9 bool fullBuild; | 9 bool fullBuild; |
10 List<String> changedFiles; | 10 List<String> changedFiles; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 /** | 93 /** |
94 * Convert a .foo file to a .foobar file. | 94 * Convert a .foo file to a .foobar file. |
95 */ | 95 */ |
96 void _processFile(String arg) { | 96 void _processFile(String arg) { |
97 if (arg.endsWith(".foo")) { | 97 if (arg.endsWith(".foo")) { |
98 print("processing: ${arg}"); | 98 print("processing: ${arg}"); |
99 | 99 |
100 File file = new File(arg); | 100 File file = new File(arg); |
101 | 101 |
102 String contents = file.readAsTextSync(); | 102 String contents = file.readAsStringSync(); |
103 | 103 |
104 File outFile = new File("${arg}bar"); | 104 File outFile = new File("${arg}bar"); |
105 | 105 |
106 OutputStream out = outFile.openOutputStream(); | 106 OutputStream out = outFile.openOutputStream(); |
107 out.writeString("Processed from ${file.name}:\n"); | 107 out.writeString("Processed from ${file.name}:\n"); |
108 if (contents != null) { | 108 if (contents != null) { |
109 out.writeString(contents); | 109 out.writeString(contents); |
110 } | 110 } |
111 out.close(); | 111 out.close(); |
112 | 112 |
113 print("wrote : ${outFile.name}"); | 113 print("wrote : ${outFile.name}"); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 /** | 117 /** |
118 * If this file is a generated file (based on the extension), delete it. | 118 * If this file is a generated file (based on the extension), delete it. |
119 */ | 119 */ |
120 void _maybeClean(String file) { | 120 void _maybeClean(String file) { |
121 if (file.endsWith(".foobar")) { | 121 if (file.endsWith(".foobar")) { |
122 new File(file).delete(); | 122 new File(file).delete(); |
123 } | 123 } |
124 } | 124 } |
OLD | NEW |