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 | 6 |
7 /** | 7 /** |
8 * This minimal build script copies the contents of .foo files to .foobar files. | 8 * This minimal build script copies the contents of .foo files to .foobar files. |
9 * In order to be invoked automatically by the Editor, this script must be named | 9 * In order to be invoked automatically by the Editor, this script must be named |
10 * 'build.dart' and placed in the root of a project. | 10 * 'build.dart' and placed in the root of a project. |
11 */ | 11 */ |
12 void main() { | 12 void main() { |
13 for (String arg in new Options().arguments) { | 13 for (String arg in new Options().arguments) { |
14 if (arg.startsWith("--changed=")) { | 14 if (arg.startsWith("--changed=")) { |
15 String file = arg.substring("--changed=".length); | 15 String file = arg.substring("--changed=".length); |
16 | 16 |
17 if (file.endsWith(".foo")) { | 17 if (file.endsWith(".foo")) { |
18 _processFile(file); | 18 _processFile(file); |
19 } | 19 } |
20 } | 20 } |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 void _processFile(String file) { | 24 void _processFile(String file) { |
25 String contents = new File(file).readAsStringSync(); | 25 String contents = new File(file).readAsStringSync(); |
26 | 26 |
27 if (contents != null) { | 27 if (contents != null) { |
28 OutputStream out = new File("${file}bar").openOutputStream(); | 28 var out = new File("${file}bar").openWrite(); |
29 out.writeString("// processed from ${file}:\n${contents}"); | 29 out.addString("// processed from ${file}:\n${contents}"); |
30 out.close(); | 30 out.close(); |
31 } | 31 } |
32 } | 32 } |
OLD | NEW |