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