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

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

Issue 11472033: Fix "src" detection in the pub lish validator on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« utils/pub/command_lish.dart ('K') | « utils/pub/command_lish.dart ('k') | no next file » | 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 name_validator; 5 library name_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 13 matching lines...) Expand all
24 24
25 Future validate() { 25 Future validate() {
26 _checkName(entrypoint.root.name, 'Package name "${entrypoint.root.name}"'); 26 _checkName(entrypoint.root.name, 'Package name "${entrypoint.root.name}"');
27 27
28 var libDir = join(entrypoint.root.dir, "lib"); 28 var libDir = join(entrypoint.root.dir, "lib");
29 return dirExists(libDir).chain((libDirExists) { 29 return dirExists(libDir).chain((libDirExists) {
30 if (!libDirExists) return new Future.immediate([]); 30 if (!libDirExists) return new Future.immediate([]);
31 return listDir(libDir, recursive: true); 31 return listDir(libDir, recursive: true);
32 }).transform((files) { 32 }).transform((files) {
33 for (var file in files) { 33 for (var file in files) {
34 if (file.contains("/src/")) continue; 34 // TODO(nweiz): Since `file` is absolute, this will break if the package
35 // itself is in a directory named "src".
36 if (splitPath(file).contains("src")) continue;
35 if (new Path(file).extension != 'dart') continue; 37 if (new Path(file).extension != 'dart') continue;
36 var libName = new Path(basename(file)).filenameWithoutExtension; 38 var libName = new Path(basename(file)).filenameWithoutExtension;
37 _checkName(libName, 'The name of "$file", "$libName",'); 39 _checkName(libName, 'The name of "$file", "$libName",');
38 } 40 }
39 }); 41 });
40 } 42 }
41 43
42 void _checkName(String name, String description) { 44 void _checkName(String name, String description) {
43 if (name == "") { 45 if (name == "") {
44 errors.add("$description may not be empty."); 46 errors.add("$description may not be empty.");
(...skipping 19 matching lines...) Expand all
64 builder 66 builder
65 ..add(source.substring(lastMatchEnd, match.start + 1)) 67 ..add(source.substring(lastMatchEnd, match.start + 1))
66 ..add("_") 68 ..add("_")
67 ..add(match.group(1).toLowerCase()); 69 ..add(match.group(1).toLowerCase());
68 lastMatchEnd = match.end; 70 lastMatchEnd = match.end;
69 } 71 }
70 builder.add(source.substring(lastMatchEnd)); 72 builder.add(source.substring(lastMatchEnd));
71 return builder.toString().toLowerCase(); 73 return builder.toString().toLowerCase();
72 } 74 }
73 } 75 }
OLDNEW
« utils/pub/command_lish.dart ('K') | « utils/pub/command_lish.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698