| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library pub.barback; | 5 library pub.barback; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 BarbackMode mode, {Iterable<Transformer> builtInTransformers, | 112 BarbackMode mode, {Iterable<Transformer> builtInTransformers, |
| 113 WatcherType watcher: WatcherType.AUTO}) { | 113 WatcherType watcher: WatcherType.AUTO}) { |
| 114 var provider = new PubPackageProvider(graph); | 114 var provider = new PubPackageProvider(graph); |
| 115 var barback = new Barback(provider); | 115 var barback = new Barback(provider); |
| 116 | 116 |
| 117 barback.log.listen(_log); | 117 barback.log.listen(_log); |
| 118 | 118 |
| 119 return BarbackServer.bind(host, port, barback, graph.entrypoint.root.name) | 119 return BarbackServer.bind(host, port, barback, graph.entrypoint.root.name) |
| 120 .then((server) { | 120 .then((server) { |
| 121 return new Future.sync(() { | 121 return new Future.sync(() { |
| 122 if (watcher == WatcherType.NONE) { | 122 if (watcher != WatcherType.NONE) { |
| 123 loadSources(graph, barback); | 123 return watchSources(graph, barback, watcher); |
| 124 return; | |
| 125 } | 124 } |
| 126 | 125 |
| 127 return watchSources(graph, barback, (directory) { | 126 loadSources(graph, barback); |
| 128 if (watcher == WatcherType.AUTO) return new DirectoryWatcher(directory); | |
| 129 return new PollingDirectoryWatcher(directory); | |
| 130 }); | |
| 131 }).then((_) { | 127 }).then((_) { |
| 132 var completer = new Completer(); | 128 var completer = new Completer(); |
| 133 | 129 |
| 134 // If any errors get emitted either by barback or by the server, including | 130 // If any errors get emitted either by barback or by the server, including |
| 135 // non-programmatic barback errors, they should take down the whole | 131 // non-programmatic barback errors, they should take down the whole |
| 136 // program. | 132 // program. |
| 137 var subscriptions = [ | 133 var subscriptions = [ |
| 138 server.barback.errors.listen((error) { | 134 server.barback.errors.listen((error) { |
| 139 if (error is TransformerException) error = error.error; | 135 if (error is TransformerException) error = error.error; |
| 140 if (!completer.isCompleted) completer.completeError(error); | 136 if (!completer.isCompleted) completer.completeError(error); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 301 |
| 306 case LogLevel.WARNING: | 302 case LogLevel.WARNING: |
| 307 log.warning("${log.yellow(prefix)}\n$message"); | 303 log.warning("${log.yellow(prefix)}\n$message"); |
| 308 break; | 304 break; |
| 309 | 305 |
| 310 case LogLevel.INFO: | 306 case LogLevel.INFO: |
| 311 log.message("$prefix\n$message"); | 307 log.message("$prefix\n$message"); |
| 312 break; | 308 break; |
| 313 } | 309 } |
| 314 } | 310 } |
| OLD | NEW |