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

Unified Diff: pkg/polymer/lib/src/build/runner.dart

Issue 26268002: Emit assets in serial, use Stream.pipe to write to output files (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: another forEach Created 7 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/runner.dart
diff --git a/pkg/polymer/lib/src/build/runner.dart b/pkg/polymer/lib/src/build/runner.dart
index 3596e923b440365a16655b2b2b44b4803fc339fc..064ac089e4b14934ab5e234949bc0a02ab9a4da3 100644
--- a/pkg/polymer/lib/src/build/runner.dart
+++ b/pkg/polymer/lib/src/build/runner.dart
@@ -210,10 +210,11 @@ Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) {
var currentPackage = options.currentPackage;
var transformTests = options.transformTests;
var outPackages = path.join(options.outDir, 'packages');
- for (var asset in assets) {
+
+ return Future.forEach(assets, (asset) {
var id = asset.id;
var dir = _firstDir(id.path);
- if (dir == null) continue;
+ if (dir == null) return null;
var filepath;
if (dir == 'lib') {
@@ -226,12 +227,11 @@ Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) {
filepath = path.join(options.outDir, _toSystemPath(id.path));
} else {
// TODO(sigmund): do something about other assets?
- continue;
+ return null;
}
- futures.add(_writeAsset(filepath, asset));
- }
- return Future.wait(futures);
+ return _writeAsset(filepath, asset);
+ });
}
/**
@@ -271,16 +271,15 @@ Future _emitPackagesDir(BarbackOptions options) {
_ensureDir(outPackages);
// Copy all the files we didn't process
- var futures = [];
var dirs = options.packageDirs;
- for (var package in _polymerPackageDependencies) {
- for (var relpath in _listPackageDir(package, 'lib', options)) {
+
+ return Future.forEach(_polymerPackageDependencies, (package) {
+ return Future.forEach(_listPackageDir(package, 'lib', options), (relpath) {
var inpath = path.join(dirs[package], relpath);
var outpath = path.join(outPackages, package, relpath.substring(4));
- futures.add(_copyFile(inpath, outpath));
- }
- }
- return Future.wait(futures);
+ return _copyFile(inpath, outpath);
+ });
+ });
}
/** Ensure [dirpath] exists. */
@@ -301,14 +300,11 @@ String _firstDir(String url) {
/** Copy a file from [inpath] to [outpath]. */
Future _copyFile(String inpath, String outpath) {
_ensureDir(path.dirname(outpath));
- var writer = new File(outpath).openWrite();
- return writer.addStream(new File(inpath).openRead())
- .then((_) => writer.close());
+ return new File(inpath).openRead().pipe(new File(outpath).openWrite());
}
/** Write contents of an [asset] into a file at [filepath]. */
Future _writeAsset(String filepath, Asset asset) {
_ensureDir(path.dirname(filepath));
- var writer = new File(filepath).openWrite();
- return writer.addStream(asset.read()).then((_) => writer.close());
+ return asset.read().pipe(new File(filepath).openWrite());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698