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

Unified Diff: utils/pub/command_lish.dart

Issue 12079112: Make a bunch of stuff in pub synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after merge. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | utils/pub/command_uploader.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/command_lish.dart
diff --git a/utils/pub/command_lish.dart b/utils/pub/command_lish.dart
index 1e5673da28f9b82319315a44d9776cff89cd891e..4a370d7d67a1815dce0c76525bb35b7b3c167b9e 100644
--- a/utils/pub/command_lish.dart
+++ b/utils/pub/command_lish.dart
@@ -109,7 +109,7 @@ class LishCommand extends PubCommand {
/// The basenames of directories that are automatically excluded from
/// archives.
- final _BLACKLISTED_DIRECTORIES = const ['packages'];
+ final _BLACKLISTED_DIRS = const ['packages'];
/// Returns a list of files that should be included in the published package.
/// If this is a Git repository, this will respect .gitignore; otherwise, it
@@ -117,11 +117,8 @@ class LishCommand extends PubCommand {
Future<List<String>> get _filesToPublish {
var rootDir = entrypoint.root.dir;
- return Future.wait([
- dirExists(join(rootDir, '.git')),
- git.isInstalled
- ]).then((results) {
- if (results[0] && results[1]) {
+ return git.isInstalled.then((gitInstalled) {
+ if (dirExists(join(rootDir, '.git')) && gitInstalled) {
// List all files that aren't gitignored, including those not checked
// in to Git.
return git.run(["ls-files", "--cached", "--others",
@@ -129,27 +126,17 @@ class LishCommand extends PubCommand {
}
return listDir(rootDir, recursive: true).then((entries) {
- return Future.wait(entries.map((entry) {
- return fileExists(entry).then((isFile) {
- // Skip directories.
- if (!isFile) return null;
-
- // TODO(rnystrom): Making these relative will break archive
- // creation if the cwd is ever *not* the package root directory.
- // Should instead only make these relative right before generating
- // the tree display (which is what really needs them to be).
- // Make it relative to the package root.
- return relativeTo(entry, rootDir);
- });
- }));
+ return entries
+ .where(fileExists) // Skip directories.
+ .map((entry) => relativeTo(entry, rootDir));
});
- }).then((files) => files.where((file) {
- if (file == null || _BLACKLISTED_FILES.contains(basename(file))) {
- return false;
- }
+ }).then((files) => files.where(_shouldPublish).toList());
+ }
- return !splitPath(file).any(_BLACKLISTED_DIRECTORIES.contains);
- }).toList());
+ /// Returns `true` if [file] should be published.
+ bool _shouldPublish(String file) {
+ if (_BLACKLISTED_FILES.contains(basename(file))) return false;
+ return !splitPath(file).any(_BLACKLISTED_DIRS.contains);
}
/// Returns the value associated with [key] in [map]. Throws a user-friendly
« no previous file with comments | « no previous file | utils/pub/command_uploader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698