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

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

Issue 11785028: Commit Martin's patch for pub + lib_v2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. 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/directory.dart ('k') | utils/pub/validator/license.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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 lib_validator; 5 library lib_validator;
6 6
7 import 'dart:async';
7 import 'dart:io'; 8 import 'dart:io';
8 9
9 import '../entrypoint.dart'; 10 import '../entrypoint.dart';
10 import '../io.dart'; 11 import '../io.dart';
11 import '../system_cache.dart'; 12 import '../system_cache.dart';
12 import '../utils.dart'; 13 import '../utils.dart';
13 import '../validator.dart'; 14 import '../validator.dart';
14 15
15 // TODO(nweiz): When issue 7196 is fixed, complain about non-Dart files in lib. 16 // TODO(nweiz): When issue 7196 is fixed, complain about non-Dart files in lib.
16 /// A validator that checks that libraries in "lib/" (and not "lib/src/") exist 17 /// A validator that checks that libraries in "lib/" (and not "lib/src/") exist
17 /// and are well-formed. 18 /// and are well-formed.
18 class LibValidator extends Validator { 19 class LibValidator extends Validator {
19 LibValidator(Entrypoint entrypoint) 20 LibValidator(Entrypoint entrypoint)
20 : super(entrypoint); 21 : super(entrypoint);
21 22
22 Future validate() { 23 Future validate() {
23 var libDir = join(entrypoint.root.dir, "lib"); 24 var libDir = join(entrypoint.root.dir, "lib");
24 25
25 return dirExists(libDir).chain((libDirExists) { 26 return dirExists(libDir).then((libDirExists) {
26 if (!libDirExists) { 27 if (!libDirExists) {
27 errors.add('You must have a "lib" directory.\n' 28 errors.add('You must have a "lib" directory.\n'
28 "Without that, users cannot import any code from your package."); 29 "Without that, users cannot import any code from your package.");
29 return new Future.immediate(null); 30 return new Future.immediate(null);
30 } 31 }
31 32
32 return listDir(libDir).then((files) { 33 return listDir(libDir).then((files) {
33 files = files.mappedBy((file) => relativeTo(file, libDir)).toList(); 34 files = files.mappedBy((file) => relativeTo(file, libDir)).toList();
34 if (files.isEmpty) { 35 if (files.isEmpty) {
35 errors.add('You must have a non-empty "lib" directory.\n' 36 errors.add('You must have a non-empty "lib" directory.\n'
36 "Without that, users cannot import any code from your package."); 37 "Without that, users cannot import any code from your package.");
37 } else if (files.length == 1 && files.first == "src") { 38 } else if (files.length == 1 && files.first == "src") {
38 errors.add('The "lib" directory must contain something other than ' 39 errors.add('The "lib" directory must contain something other than '
39 '"src".\n' 40 '"src".\n'
40 "Otherwise, users cannot import any code from your package."); 41 "Otherwise, users cannot import any code from your package.");
41 } 42 }
42 }); 43 });
43 }); 44 });
44 } 45 }
45 } 46 }
OLDNEW
« no previous file with comments | « utils/pub/validator/directory.dart ('k') | utils/pub/validator/license.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698