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

Unified Diff: lib/src/validator/pubspec.dart

Issue 1310253007: Make pub lish validation gitignore-aware. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: analysis hints Created 5 years, 4 months 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
Index: lib/src/validator/pubspec.dart
diff --git a/lib/src/validator/pubspec.dart b/lib/src/validator/pubspec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f1ca4a4e82d4e5e328f7d3af09a0558238924bfd
--- /dev/null
+++ b/lib/src/validator/pubspec.dart
@@ -0,0 +1,29 @@
+// Copyright (c) 2015, 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 pub.validator.pubspec;
+
+import 'dart:async';
+
+import 'package:path/path.dart' as p;
+
+import '../entrypoint.dart';
+import '../validator.dart';
+
+/// Validates that a package's pubspec exists.
+///
+/// In most cases this is clearly true, since pub can't run without a pubspec,
+/// but it's possible that the pubspec is gitignored.
+class PubspecValidator extends Validator {
+ PubspecValidator(Entrypoint entrypoint)
+ : super(entrypoint);
+
+ Future validate() async {
+ var files = entrypoint.root.listFiles(recursive: false, useGitIgnore: true);
+ if (!files.any((file) => p.basename(file) == "pubspec.yaml")) {
+ errors.add("The pubspec is hidden, probably by .gitignore.");
+ }
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698