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