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

Side by Side Diff: utils/pub/validator/directory.dart

Issue 11741026: Add a validator for top-level directory names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/validator.dart ('k') | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 library directory_validator;
6
7 import '../entrypoint.dart';
8 import '../io.dart';
9 import '../validator.dart';
10
11 /// A validator that validates a package's top-level directories.
12 class DirectoryValidator extends Validator {
13 DirectoryValidator(Entrypoint entrypoint)
14 : super(entrypoint);
15
16 static final _PLURAL_NAMES = ["tools", "tests", "docs", "examples"];
17
18 Future validate() {
19 return listDir(entrypoint.root.dir).chain((dirs) {
20 return Futures.wait(dirs.map((dir) {
21 return dirExists(dir).transform((exists) {
22 if (!exists) return;
23
24 dir = basename(dir);
25 if (_PLURAL_NAMES.contains(dir)) {
26 // Cut off the "s"
27 var singularName = dir.substring(0, dir.length - 1);
28 warnings.add('Rename the top-level "$dir" directory to '
29 '"$singularName".\n'
30 'The Pub layout convention is to use singular directory '
31 'names.\n'
32 'Plural names won\'t be correctly identified by Pub and other '
33 'tools.');
Bob Nystrom 2013/01/03 23:18:54 How about: ''Rename the top-level "$dir" director
nweiz 2013/01/04 00:25:15 That doesn't really make sense for "doc", and I th
34 }
35
36 if (dir.contains(new RegExp(r"^samples?$"))) {
37 warnings.add('Rename the top-level "$dir" directory to "example".\n'
38 'This allows Pub to find your examples and create "packages" '
39 'directories for them.\n');
40 }
41 });
42 }));
43 });
44 }
45 }
OLDNEW
« no previous file with comments | « utils/pub/validator.dart ('k') | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698