Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/command/build.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/command/build.dart b/sdk/lib/_internal/pub/lib/src/command/build.dart |
| index 7a6685a60a69ec730d8f198baadd402b9b2ee40d..c3b77e9f2b018161f37c77bc33cddc4e4b8a5da3 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/command/build.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/command/build.dart |
| @@ -92,8 +92,9 @@ class BuildCommand extends BarbackCommand { |
| .where((asset) => asset.id.path.endsWith(".dart.js")) |
| .map((asset) => asset.id); |
| - return Future.wait(assets.map(_writeAsset)).then((_) { |
| - builtFiles += _copyBrowserJsFiles(dart2JSEntrypoints); |
| + return Future.wait(assets.map(_writeAsset)) |
| + .then((_) => _copyBrowserJsFiles(dart2JSEntrypoints, assets)) |
| + .then((_) { |
|
Bob Nystrom
2015/03/12 22:36:08
In pub, we tend to leave .then() hanging on the ri
Chris Bracken
2015/03/12 22:52:42
Done.
|
| log.message('Built $builtFiles ${pluralize('file', builtFiles)} ' |
| 'to "$outputDirectory".'); |
| @@ -190,13 +191,11 @@ class BuildCommand extends BarbackCommand { |
| /// If this package depends directly on the `browser` package, this ensures |
| /// that the JavaScript bootstrap files are copied into `packages/browser/` |
| /// directories next to each entrypoint in [entrypoints]. |
| - /// |
| - /// Returns the number of files it copied. |
|
Bob Nystrom
2015/03/12 22:36:08
Can you preserve this behavior? It should be fairl
Chris Bracken
2015/03/12 22:52:42
Is there a good reason to? The new code uses _writ
Bob Nystrom
2015/03/13 16:20:21
Ack, my reading comprehension was bad here. Sorry.
|
| - int _copyBrowserJsFiles(Iterable<AssetId> entrypoints) { |
| + Future _copyBrowserJsFiles(Iterable<AssetId> entrypoints, AssetSet assets) { |
|
Bob Nystrom
2015/03/12 22:36:08
Feel free to use async/await here to make your lif
|
| // Must depend on the browser package. |
| if (!entrypoint.root.immediateDependencies.any( |
| (dep) => dep.name == 'browser' && dep.source == 'hosted')) { |
| - return 0; |
| + return new Future.value(); |
| } |
| // Get all of the subdirectories that contain Dart entrypoints. |
| @@ -209,29 +208,17 @@ class BuildCommand extends BarbackCommand { |
| .where((dir) => path.split(dir).length > 1) |
| .toSet(); |
| - for (var dir in entrypointDirs) { |
| + var jsAssets = assets.where((asset) => |
| + asset.id.package == 'browser' && asset.id.extension == '.js'); |
| + return Future.wait(entrypointDirs.expand((dir) { |
| // TODO(nweiz): we should put browser JS files next to any HTML file |
| // rather than any entrypoint. An HTML file could import an entrypoint |
| // that's not adjacent. |
| - _addBrowserJs(dir, "dart"); |
| - _addBrowserJs(dir, "interop"); |
| - } |
| - |
| - return entrypointDirs.length * 2; |
| - } |
| - |
| - // TODO(nweiz): do something more principled when issue 6101 is fixed. |
| - /// Ensures that the [name].js file is copied into [directory] in [target], |
| - /// under `packages/browser/`. |
| - void _addBrowserJs(String directory, String name) { |
| - var jsPath = entrypoint.root.path( |
| - outputDirectory, directory, 'packages', 'browser', '$name.js'); |
| - ensureDir(path.dirname(jsPath)); |
| - |
| - // TODO(rnystrom): This won't work if we get rid of symlinks and the top |
| - // level "packages" directory. Will need to copy from the browser |
| - // directory. |
| - copyFile(path.join(entrypoint.packagesDir, 'browser', '$name.js'), jsPath); |
| + return jsAssets.map((asset) { |
| + var jsPath = path.join(dir, _idToPath(asset.id)); |
| + return _writeOutputFile(asset, jsPath); |
| + }); |
| + })); |
| } |
| /// Converts [entry] to a JSON object for use with JSON-formatted output. |