Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3508)

Unified Diff: utils/pub/validator/license.dart

Issue 11474047: Validate that an uploaded package has a LICENSE file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/validator.dart ('k') | utils/tests/pub/oauth2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.");
+ });
+ }
+}
« no previous file with comments | « utils/pub/validator.dart ('k') | utils/tests/pub/oauth2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698