Chromium Code Reviews| Index: pkg/barback/lib/src/asset_cascade.dart |
| diff --git a/pkg/barback/lib/src/asset_cascade.dart b/pkg/barback/lib/src/asset_cascade.dart |
| index f123cf38376ca0ea6bb2bf46a7b59ebc0511719c..9eec80041c467d9fec3eb872676b90fb399c150f 100644 |
| --- a/pkg/barback/lib/src/asset_cascade.dart |
| +++ b/pkg/barback/lib/src/asset_cascade.dart |
| @@ -11,6 +11,7 @@ import 'asset.dart'; |
| import 'asset_id.dart'; |
| import 'asset_node.dart'; |
| import 'asset_set.dart'; |
| +import 'barback_logger.dart'; |
| import 'build_result.dart'; |
| import 'cancelable_future.dart'; |
| import 'errors.dart'; |
| @@ -84,11 +85,20 @@ class AssetCascade { |
| /// A controller whose stream feeds into [_onDirtyPool]. |
| final _onDirtyController = new StreamController.broadcast(sync: true); |
| + /// A stream that emits an event whenever any transforms in this cascade log |
|
nweiz
2013/10/16 19:41:27
"log" -> "logs"
Bob Nystrom
2013/10/28 23:45:56
Done.
|
| + /// an entry. |
| + Stream<LogEntry> get onLog => _onLogPool.stream; |
| + final _onLogPool = new StreamPool<LogEntry>.broadcast(); |
| + |
| /// The errors that have occurred since the current build started. |
| /// |
| /// This will be empty if no build is occurring. |
| Queue<BarbackException> _accumulatedErrors; |
| + /// The number of errors that have been logged since the current build |
| + /// started. |
| + int _numLogErrors; |
| + |
| /// A future that completes when the currently running build process finishes. |
| /// |
| /// If no build it in progress, is `null`. |
| @@ -108,6 +118,11 @@ class AssetCascade { |
| AssetCascade(this.graph, this.package) { |
| _onDirtyPool.add(_onDirtyController.stream); |
| _addPhase(new Phase(this, [])); |
| + |
| + // Keep track of logged errors so we can know that the build failed. |
| + onLog.listen((entry) { |
| + if (entry.level == LogLevel.ERROR) _numLogErrors++; |
| + }); |
| } |
| /// Gets the asset identified by [id]. |
| @@ -222,6 +237,7 @@ class AssetCascade { |
| /// Add [phase] to the end of [_phases] and watch its [onDirty] stream. |
| void _addPhase(Phase phase) { |
| _onDirtyPool.add(phase.onDirty); |
| + _onLogPool.add(phase.onLog); |
| phase.onDirty.listen((_) { |
| _newChanges = true; |
| _waitForProcess(); |
| @@ -240,10 +256,12 @@ class AssetCascade { |
| if (_processDone != null) return _processDone; |
| _accumulatedErrors = new Queue(); |
| + _numLogErrors = 0; |
| return _processDone = _process().then((_) { |
| // Report the build completion. |
| // TODO(rnystrom): Put some useful data in here. |
| - _resultsController.add(new BuildResult(_accumulatedErrors)); |
| + _resultsController.add( |
| + new BuildResult(_accumulatedErrors, _numLogErrors)); |
| }).catchError((error) { |
| // If we get here, it's an unexpected error. Runtime errors like missing |
| // assets should be handled earlier. Errors from transformers or other |