Chromium Code Reviews| Index: utils/pub/validator/license.dart |
| diff --git a/utils/pub/validator/license.dart b/utils/pub/validator/license.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..46a1c4087669fb179451ea76b70112d5184361ff |
| --- /dev/null |
| +++ b/utils/pub/validator/license.dart |
| @@ -0,0 +1,28 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library pubspec_field_validator; |
| + |
| +import '../entrypoint.dart'; |
| +import '../io.dart'; |
| +import '../system_cache.dart'; |
| +import '../validator.dart'; |
| + |
| +/// A validator that checks that a LICENSE-like file exists. |
| +class LicenseValidator extends Validator { |
| + LicenseValidator(Entrypoint entrypoint) |
| + : super(entrypoint); |
| + |
| + Future validate() { |
| + return listDir(entrypoint.root.dir).transform((files) { |
|
Bob Nystrom
2012/12/08 03:21:50
Does this do a recursive list?
nweiz
2012/12/08 03:24:27
No, we don't want it picking up files in third_par
|
| + var licenseLike = new RegExp( |
| + r"^([a-zA-Z0-9]+[-_])?(LICENSE|COPYING)(\..*)?$"); |
| + if (files.map(basename).some(licenseLike.hasMatch)) return; |
| + |
| + errors.add("Your package must have a COPYING or LICENSE file containing " |
| + "an open-source license. For more details, see " |
| + "http://pub.dartlang.org/doc/pub-lish.html."); |
| + }); |
| + } |
| +} |