| Index: pkg/barback/lib/src/package_graph.dart
|
| diff --git a/pkg/barback/lib/src/package_graph.dart b/pkg/barback/lib/src/package_graph.dart
|
| index 639deea6f49300cb47f6e4729e07d787a45a93e6..b0e3135bbe846fee2816a9ce2717fa95fb746b64 100644
|
| --- a/pkg/barback/lib/src/package_graph.dart
|
| +++ b/pkg/barback/lib/src/package_graph.dart
|
| @@ -9,6 +9,7 @@ import 'dart:async';
|
| import 'asset_cascade.dart';
|
| import 'asset_id.dart';
|
| import 'asset_node.dart';
|
| +import 'asset_set.dart';
|
| import 'build_result.dart';
|
| import 'errors.dart';
|
| import 'package_provider.dart';
|
| @@ -92,6 +93,31 @@ class PackageGraph {
|
| return new Future.value(null);
|
| }
|
|
|
| + /// Gets all output assets.
|
| + ///
|
| + /// If a build is currently in progress, waits until it completes. The
|
| + /// returned future will complete with an error if the build is not
|
| + /// successful.
|
| + Future<AssetSet> getAllAssets() {
|
| + if (_cascadeResults.values.contains(null)) {
|
| + // A build is still ongoing, so wait for it to complete and try again.
|
| + return results.first.then((_) => getAllAssets());
|
| + }
|
| +
|
| + // If the build completed with an error, complete the future with it.
|
| + var errors = unionAll(
|
| + _cascadeResults.values.map((result) => result.errors));
|
| + if (errors.isNotEmpty) {
|
| + return new Future.error(BarbackException.aggregate(errors));
|
| + }
|
| +
|
| + // Otherwise, return all of the final output assets.
|
| + var assets = unionAll(_cascades.values.map(
|
| + (cascade) => cascade.availableOutputs.toSet()));
|
| +
|
| + return new Future.value(new AssetSet.from(assets));
|
| + }
|
| +
|
| /// Adds [sources] to the graph's known set of source assets.
|
| ///
|
| /// Begins applying any transforms that can consume any of the sources. If a
|
|
|