Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/barback.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/barback.dart b/sdk/lib/_internal/pub/lib/src/barback.dart |
| index 7e317f63ecccb05af3aa98d1b09df49c5744a79e..e2f32bacfd1bb57f19053ddae88b0d81eb039533 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/barback.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/barback.dart |
| @@ -8,6 +8,7 @@ import 'dart:async'; |
| import 'package:barback/barback.dart'; |
| import 'package:path/path.dart' as path; |
| +import 'package:watcher/watcher.dart'; |
| import 'barback/load_all_transformers.dart'; |
| import 'barback/pub_package_provider.dart'; |
| @@ -108,7 +109,7 @@ class TransformerId { |
| /// the app when the server is started will be maintained. |
| Future<BarbackServer> createServer(String host, int port, PackageGraph graph, |
| BarbackMode mode, {Iterable<Transformer> builtInTransformers, |
| - bool watchForUpdates: true}) { |
| + WatcherType watcher: WatcherType.AUTO}) { |
| var provider = new PubPackageProvider(graph); |
| var barback = new Barback(provider); |
| @@ -117,8 +118,15 @@ Future<BarbackServer> createServer(String host, int port, PackageGraph graph, |
| return BarbackServer.bind(host, port, barback, graph.entrypoint.root.name) |
| .then((server) { |
| return new Future.sync(() { |
| - if (watchForUpdates) return watchSources(graph, barback); |
| - loadSources(graph, barback); |
| + if (watcher == WatcherType.NONE) { |
| + loadSources(graph, barback); |
| + return; |
| + } |
| + |
| + return watchSources(graph, barback, (directory) { |
| + if (watcher == WatcherType.AUTO) return new DirectoryWatcher(directory); |
| + return new PollingDirectoryWatcher(directory); |
|
Bob Nystrom
2013/11/08 01:32:32
How about making this a factory method on WatcherT
nweiz
2013/11/08 01:44:24
Done.
|
| + }); |
| }).then((_) { |
| var completer = new Completer(); |
| @@ -155,6 +163,20 @@ Future<BarbackServer> createServer(String host, int port, PackageGraph graph, |
| }); |
| } |
| +class WatcherType { |
| + static const AUTO = const WatcherType._("auto"); |
| + |
| + static const POLLING = const WatcherType._("polling"); |
| + |
| + static const NONE = const WatcherType._("none"); |
| + |
| + final String _name; |
| + |
| + const WatcherType._(this._name); |
| + |
| + String toString() => _name; |
| +} |
| + |
| /// Converts [id] to a "package:" URI. |
| /// |
| /// This will throw an [ArgumentError] if [id] doesn't represent a library in |