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 validator; | 5 library validator; |
6 | 6 |
7 import 'entrypoint.dart'; | 7 import 'entrypoint.dart'; |
8 import 'log.dart' as log; | 8 import 'log.dart' as log; |
9 import 'io.dart'; | 9 import 'io.dart'; |
10 import 'system_cache.dart'; | 10 import 'system_cache.dart'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 new NameValidator(entrypoint), | 48 new NameValidator(entrypoint), |
49 new PubspecFieldValidator(entrypoint), | 49 new PubspecFieldValidator(entrypoint), |
50 new DependencyValidator(entrypoint), | 50 new DependencyValidator(entrypoint), |
51 new DirectoryValidator(entrypoint) | 51 new DirectoryValidator(entrypoint) |
52 ]; | 52 ]; |
53 | 53 |
54 // TODO(nweiz): The sleep 0 here forces us to go async. This works around | 54 // TODO(nweiz): The sleep 0 here forces us to go async. This works around |
55 // 3356, which causes a bug if all validators are (synchronously) using | 55 // 3356, which causes a bug if all validators are (synchronously) using |
56 // Future.immediate and an error is thrown before a handler is set up. | 56 // Future.immediate and an error is thrown before a handler is set up. |
57 return sleep(0).chain((_) { | 57 return sleep(0).chain((_) { |
58 return Futures.wait(validators.map((validator) => validator.validate())); | 58 return Futures.wait( |
59 }).transform((_) { | 59 validators.mappedBy((validator) => validator.validate())); |
60 var errors = flatten(validators.map((validator) => validator.errors)); | 60 }).then((_) { |
61 var warnings = flatten(validators.map((validator) => validator.warnings)); | 61 var errors = |
| 62 flatten(validators.mappedBy((validator) => validator.errors)); |
| 63 var warnings = |
| 64 flatten(validators.mappedBy((validator) => validator.warnings)); |
62 | 65 |
63 if (!errors.isEmpty) { | 66 if (!errors.isEmpty) { |
64 log.error("Missing requirements:"); | 67 log.error("Missing requirements:"); |
65 for (var error in errors) { | 68 for (var error in errors) { |
66 log.error("* ${Strings.join(error.split('\n'), '\n ')}"); | 69 log.error("* ${Strings.join(error.split('\n'), '\n ')}"); |
67 } | 70 } |
68 log.error(""); | 71 log.error(""); |
69 } | 72 } |
70 | 73 |
71 if (!warnings.isEmpty) { | 74 if (!warnings.isEmpty) { |
72 log.warning("Suggestions:"); | 75 log.warning("Suggestions:"); |
73 for (var warning in warnings) { | 76 for (var warning in warnings) { |
74 log.warning("* ${Strings.join(warning.split('\n'), '\n ')}"); | 77 log.warning("* ${Strings.join(warning.split('\n'), '\n ')}"); |
75 } | 78 } |
76 log.warning(""); | 79 log.warning(""); |
77 } | 80 } |
78 | 81 |
79 return new Pair<List<String>, List<String>>(errors, warnings); | 82 return new Pair<List<String>, List<String>>(errors, warnings); |
80 }); | 83 }); |
81 } | 84 } |
82 } | 85 } |
OLD | NEW |