| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 new LicenseValidator(entrypoint), | 47 new LicenseValidator(entrypoint), |
| 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).then((_) { |
| 58 return Futures.wait( | 58 return Futures.wait( |
| 59 validators.mappedBy((validator) => validator.validate())); | 59 validators.mappedBy((validator) => validator.validate())); |
| 60 }).then((_) { | 60 }).then((_) { |
| 61 var errors = | 61 var errors = |
| 62 flatten(validators.mappedBy((validator) => validator.errors)); | 62 flatten(validators.mappedBy((validator) => validator.errors)); |
| 63 var warnings = | 63 var warnings = |
| 64 flatten(validators.mappedBy((validator) => validator.warnings)); | 64 flatten(validators.mappedBy((validator) => validator.warnings)); |
| 65 | 65 |
| 66 if (!errors.isEmpty) { | 66 if (!errors.isEmpty) { |
| 67 log.error("Missing requirements:"); | 67 log.error("Missing requirements:"); |
| 68 for (var error in errors) { | 68 for (var error in errors) { |
| 69 log.error("* ${Strings.join(error.split('\n'), '\n ')}"); | 69 log.error("* ${Strings.join(error.split('\n'), '\n ')}"); |
| 70 } | 70 } |
| 71 log.error(""); | 71 log.error(""); |
| 72 } | 72 } |
| 73 | 73 |
| 74 if (!warnings.isEmpty) { | 74 if (!warnings.isEmpty) { |
| 75 log.warning("Suggestions:"); | 75 log.warning("Suggestions:"); |
| 76 for (var warning in warnings) { | 76 for (var warning in warnings) { |
| 77 log.warning("* ${Strings.join(warning.split('\n'), '\n ')}"); | 77 log.warning("* ${Strings.join(warning.split('\n'), '\n ')}"); |
| 78 } | 78 } |
| 79 log.warning(""); | 79 log.warning(""); |
| 80 } | 80 } |
| 81 | 81 |
| 82 return new Pair<List<String>, List<String>>(errors, warnings); | 82 return new Pair<List<String>, List<String>>(errors, warnings); |
| 83 }); | 83 }); |
| 84 } | 84 } |
| 85 } | 85 } |
| OLD | NEW |