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; | 5 library build_dart; |
6 | 6 |
7 import "dart:io"; | 7 import "dart:io"; |
8 import "package:args/args.dart"; | 8 import "package:args/args.dart"; |
9 | 9 |
10 bool cleanBuild; | 10 bool cleanBuild; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 useMachineInterface = args["machine"]; | 65 useMachineInterface = args["machine"]; |
66 | 66 |
67 cleanBuild = args["clean"]; | 67 cleanBuild = args["clean"]; |
68 fullBuild = args["full"]; | 68 fullBuild = args["full"]; |
69 } | 69 } |
70 | 70 |
71 /** | 71 /** |
72 * Delete all generated files. | 72 * Delete all generated files. |
73 */ | 73 */ |
74 void handleCleanCommand() { | 74 void handleCleanCommand() { |
75 Directory current = new Directory.current(); | 75 Directory current = Directory.current; |
76 current.list(recursive: true).listen((FileSystemEntity entity) { | 76 current.list(recursive: true).listen((FileSystemEntity entity) { |
77 if (entity is File) _maybeClean(entity); | 77 if (entity is File) _maybeClean(entity); |
78 }); | 78 }); |
79 } | 79 } |
80 | 80 |
81 /** | 81 /** |
82 * Recursively scan the current directory looking for .foo files to process. | 82 * Recursively scan the current directory looking for .foo files to process. |
83 */ | 83 */ |
84 void handleFullBuild() { | 84 void handleFullBuild() { |
85 var files = <String>[]; | 85 var files = <String>[]; |
86 | 86 |
87 new Directory.current().list(recursive: true).listen( | 87 Directory.current.list(recursive: true).listen( |
88 (FileSystemEntity entity) { | 88 (FileSystemEntity entity) { |
89 if (entity is File) files.add(entity.fullPathSync()); | 89 if (entity is File) files.add(entity.fullPathSync()); |
90 }, | 90 }, |
91 onDone: () => handleChangedFiles(files)); | 91 onDone: () => handleChangedFiles(files)); |
92 } | 92 } |
93 | 93 |
94 /** | 94 /** |
95 * Process the given list of changed files. | 95 * Process the given list of changed files. |
96 */ | 96 */ |
97 void handleChangedFiles(List<String> files) { | 97 void handleChangedFiles(List<String> files) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 /** | 150 /** |
151 * If this file is a generated file (based on the extension), delete it. | 151 * If this file is a generated file (based on the extension), delete it. |
152 */ | 152 */ |
153 void _maybeClean(File file) { | 153 void _maybeClean(File file) { |
154 if (file.path.endsWith(".foobar")) { | 154 if (file.path.endsWith(".foobar")) { |
155 file.delete(); | 155 file.delete(); |
156 } | 156 } |
157 } | 157 } |
OLD | NEW |