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

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

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. Created 7 years, 8 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:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:pathos/path.dart' as path; 10 import 'package:pathos/path.dart' as path;
11 11
12 import '../entrypoint.dart'; 12 import '../entrypoint.dart';
13 import '../io.dart'; 13 import '../io.dart';
14 import '../system_cache.dart'; 14 import '../system_cache.dart';
15 import '../utils.dart'; 15 import '../utils.dart';
16 import '../validator.dart'; 16 import '../validator.dart';
17 17
18 // TODO(nweiz): When issue 7196 is fixed, complain about non-Dart files in lib. 18 // TODO(nweiz): When issue 7196 is fixed, complain about non-Dart files in lib.
19 /// A validator that checks that libraries in "lib/" (and not "lib/src/") exist 19 /// A validator that checks that libraries in "lib/" (and not "lib/src/") exist
20 /// and are well-formed. 20 /// and are well-formed.
21 class LibValidator extends Validator { 21 class LibValidator extends Validator {
22 LibValidator(Entrypoint entrypoint) 22 LibValidator(Entrypoint entrypoint)
23 : super(entrypoint); 23 : super(entrypoint);
24 24
25 Future validate() { 25 Future validate() {
26 return new Future.of(() { 26 return new Future.sync(() {
27 var libDir = path.join(entrypoint.root.dir, "lib"); 27 var libDir = path.join(entrypoint.root.dir, "lib");
28 28
29 if (!dirExists(libDir)) { 29 if (!dirExists(libDir)) {
30 errors.add('You must have a "lib" directory.\n' 30 errors.add('You must have a "lib" directory.\n'
31 "Without that, users cannot import any code from your package."); 31 "Without that, users cannot import any code from your package.");
32 return; 32 return;
33 } 33 }
34 34
35 var files = listDir(libDir) 35 var files = listDir(libDir)
36 .map((file) => path.relative(file, from: libDir)) 36 .map((file) => path.relative(file, from: libDir))
37 .toList(); 37 .toList();
38 if (files.isEmpty) { 38 if (files.isEmpty) {
39 errors.add('You must have a non-empty "lib" directory.\n' 39 errors.add('You must have a non-empty "lib" directory.\n'
40 "Without that, users cannot import any code from your package."); 40 "Without that, users cannot import any code from your package.");
41 } else if (files.length == 1 && files.first == "src") { 41 } else if (files.length == 1 && files.first == "src") {
42 errors.add('The "lib" directory must contain something other than ' 42 errors.add('The "lib" directory must contain something other than '
43 '"src".\n' 43 '"src".\n'
44 "Otherwise, users cannot import any code from your package."); 44 "Otherwise, users cannot import any code from your package.");
45 } 45 }
46 }); 46 });
47 } 47 }
48 } 48 }
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