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

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

Issue 11557008: Make pub publish more user friendly: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Blacklist '.DS_Store' files from publish. Created 8 years 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
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:io'; 7 import 'dart:io';
8 8
9 import '../entrypoint.dart'; 9 import '../entrypoint.dart';
10 import '../io.dart'; 10 import '../io.dart';
11 import '../system_cache.dart'; 11 import '../system_cache.dart';
12 import '../utils.dart'; 12 import '../utils.dart';
13 import '../validator.dart'; 13 import '../validator.dart';
14 14
15 // TODO(nweiz): When issue 7196 is fixed, complain about non-Dart files in lib. 15 // 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 16 /// A validator that checks that libraries in "lib/" (and not "lib/src/") exist
17 /// and are well-formed. 17 /// and are well-formed.
18 class LibValidator extends Validator { 18 class LibValidator extends Validator {
19 LibValidator(Entrypoint entrypoint) 19 LibValidator(Entrypoint entrypoint)
20 : super(entrypoint); 20 : super(entrypoint);
21 21
22 Future validate() { 22 Future validate() {
23 var libDir = join(entrypoint.root.dir, "lib"); 23 var libDir = join(entrypoint.root.dir, "lib");
24 return dirExists(libDir).chain((libDirExists) { 24 return dirExists(libDir).chain((libDirExists) {
25 if (!libDirExists) { 25 if (!libDirExists) {
26 errors.add('Your package must have a "lib/" directory so users have ' 26 errors.add('You must have a "lib" directory.\n'
27 'something to import.'); 27 "Without that, users cannot import any code from your package.");
28 return new Future.immediate(null); 28 return new Future.immediate(null);
29 } 29 }
30 30
31 return listDir(libDir).transform((files) { 31 return listDir(libDir).transform((files) {
32 files = files.map((file) => relativeTo(file, libDir)); 32 files = files.map((file) => relativeTo(file, libDir));
33 if (files.isEmpty) { 33 if (files.isEmpty) {
34 errors.add('The "lib/" directory may not be empty so users have ' 34 errors.add('You must have a non-empty "lib" directory.\n'
35 'something to import'); 35 "Without that, users cannot import any code from your package.");
36 } else if (files.length == 1 && files.first == "src") { 36 } else if (files.length == 1 && files.first == "src") {
37 errors.add('The "lib/" directory must contain something other than ' 37 errors.add('The "lib" directory must contain something other than '
38 '"src/" so users have something to import'); 38 '"src".\n'
39 "Otherwise, users cannot import any code from your package.");
nweiz 2012/12/12 21:21:21 Nit: why "Otherwise" here and "Without that" in th
Bob Nystrom 2012/12/12 21:45:36 It felt weird to me to have "without that" referri
39 } 40 }
40 }); 41 });
41 }); 42 });
42 } 43 }
43 } 44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698