OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 pub.validator.pubspec; | |
6 | |
7 import 'dart:async'; | 5 import 'dart:async'; |
8 | 6 |
9 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
10 | 8 |
11 import '../entrypoint.dart'; | 9 import '../entrypoint.dart'; |
12 import '../validator.dart'; | 10 import '../validator.dart'; |
13 | 11 |
14 /// Validates that a package's pubspec exists. | 12 /// Validates that a package's pubspec exists. |
15 /// | 13 /// |
16 /// In most cases this is clearly true, since pub can't run without a pubspec, | 14 /// In most cases this is clearly true, since pub can't run without a pubspec, |
17 /// but it's possible that the pubspec is gitignored. | 15 /// but it's possible that the pubspec is gitignored. |
18 class PubspecValidator extends Validator { | 16 class PubspecValidator extends Validator { |
19 PubspecValidator(Entrypoint entrypoint) | 17 PubspecValidator(Entrypoint entrypoint) |
20 : super(entrypoint); | 18 : super(entrypoint); |
21 | 19 |
22 Future validate() async { | 20 Future validate() async { |
23 var files = entrypoint.root.listFiles(recursive: false, useGitIgnore: true); | 21 var files = entrypoint.root.listFiles(recursive: false, useGitIgnore: true); |
24 if (!files.any((file) => p.basename(file) == "pubspec.yaml")) { | 22 if (!files.any((file) => p.basename(file) == "pubspec.yaml")) { |
25 errors.add("The pubspec is hidden, probably by .gitignore."); | 23 errors.add("The pubspec is hidden, probably by .gitignore."); |
26 } | 24 } |
27 } | 25 } |
28 } | 26 } |
29 | 27 |
OLD | NEW |