| Index: sdk/lib/_internal/pub_generated/lib/src/validator/directory.dart
|
| diff --git a/sdk/lib/_internal/pub_generated/lib/src/validator/directory.dart b/sdk/lib/_internal/pub_generated/lib/src/validator/directory.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..133b3da4fc909273023fa3e4a20f1ec1a1924423
|
| --- /dev/null
|
| +++ b/sdk/lib/_internal/pub_generated/lib/src/validator/directory.dart
|
| @@ -0,0 +1,37 @@
|
| +library pub.validator.directory;
|
| +import 'dart:async';
|
| +import 'package:path/path.dart' as path;
|
| +import '../entrypoint.dart';
|
| +import '../io.dart';
|
| +import '../utils.dart';
|
| +import '../validator.dart';
|
| +class DirectoryValidator extends Validator {
|
| + DirectoryValidator(Entrypoint entrypoint) : super(entrypoint);
|
| + static final _PLURAL_NAMES = [
|
| + "benchmarks",
|
| + "docs",
|
| + "examples",
|
| + "tests",
|
| + "tools"];
|
| + Future validate() {
|
| + return syncFuture(() {
|
| + for (var dir in listDir(entrypoint.root.dir)) {
|
| + if (!dirExists(dir)) continue;
|
| + dir = path.basename(dir);
|
| + if (_PLURAL_NAMES.contains(dir)) {
|
| + var singularName = dir.substring(0, dir.length - 1);
|
| + warnings.add(
|
| + 'Rename the top-level "$dir" directory to ' '"$singularName".\n'
|
| + 'The Pub layout convention is to use singular directory ' 'names.\n'
|
| + 'Plural names won\'t be correctly identified by Pub and other ' 'tools.');
|
| + }
|
| + if (dir.contains(new RegExp(r"^samples?$"))) {
|
| + warnings.add(
|
| + 'Rename the top-level "$dir" directory to "example".\n'
|
| + 'This allows Pub to find your examples and create "packages" '
|
| + 'directories for them.\n');
|
| + }
|
| + }
|
| + });
|
| + }
|
| +}
|
|
|