| OLD | NEW |
| 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'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 Future validate() { | 22 Future validate() { |
| 23 var libDir = join(entrypoint.root.dir, "lib"); | 23 var libDir = join(entrypoint.root.dir, "lib"); |
| 24 | 24 |
| 25 return dirExists(libDir).chain((libDirExists) { | 25 return dirExists(libDir).chain((libDirExists) { |
| 26 if (!libDirExists) { | 26 if (!libDirExists) { |
| 27 errors.add('You must have a "lib" directory.\n' | 27 errors.add('You must have a "lib" directory.\n' |
| 28 "Without that, users cannot import any code from your package."); | 28 "Without that, users cannot import any code from your package."); |
| 29 return new Future.immediate(null); | 29 return new Future.immediate(null); |
| 30 } | 30 } |
| 31 | 31 |
| 32 return listDir(libDir).transform((files) { | 32 return listDir(libDir).then((files) { |
| 33 files = files.map((file) => relativeTo(file, libDir)); | 33 files = files.mappedBy((file) => relativeTo(file, libDir)).toList(); |
| 34 if (files.isEmpty) { | 34 if (files.isEmpty) { |
| 35 errors.add('You must have a non-empty "lib" directory.\n' | 35 errors.add('You must have a non-empty "lib" directory.\n' |
| 36 "Without that, users cannot import any code from your package."); | 36 "Without that, users cannot import any code from your package."); |
| 37 } else if (files.length == 1 && files.first == "src") { | 37 } else if (files.length == 1 && files.first == "src") { |
| 38 errors.add('The "lib" directory must contain something other than ' | 38 errors.add('The "lib" directory must contain something other than ' |
| 39 '"src".\n' | 39 '"src".\n' |
| 40 "Otherwise, users cannot import any code from your package."); | 40 "Otherwise, users cannot import any code from your package."); |
| 41 } | 41 } |
| 42 }); | 42 }); |
| 43 }); | 43 }); |
| 44 } | 44 } |
| 45 } | 45 } |
| OLD | NEW |