Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/command/serve.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/command/serve.dart b/sdk/lib/_internal/pub/lib/src/command/serve.dart |
| index 69d92a1f6085e33b1ca9a41004e0b2438f2dfe4d..2e6d60ba4d47598548efdf35292c4382bb1e5ee9 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/command/serve.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/command/serve.dart |
| @@ -9,6 +9,7 @@ import 'dart:io'; |
| import 'package:barback/barback.dart'; |
| import 'package:path/path.dart' as path; |
| +import 'package:watcher/watcher.dart'; |
| import '../command.dart'; |
| import '../entrypoint.dart'; |
| @@ -81,6 +82,20 @@ class ServeCommand extends PubCommand { |
| // Add all of the visible files. |
| for (var package in provider.packages) { |
| barback.updateSources(provider.listAssets(package)); |
| + |
| + // Watch the package for changes. |
| + var packageDir = provider.getPackageDir(package); |
| + var watcher = new DirectoryWatcher(packageDir); |
| + watcher.events.listen((event) { |
|
nweiz
2013/08/13 00:48:45
If we're watching for any changes in the entire pa
Bob Nystrom
2013/08/14 23:58:36
Done.
|
| + var relativePath = path.relative(event.path, from: packageDir); |
| + var id = new AssetId(package, relativePath); |
| + log.message("${event.type} $id"); |
|
nweiz
2013/08/13 00:48:45
I'm not a huge fan of exposing the weird "pkg|path
Bob Nystrom
2013/08/14 23:58:36
Removed this. I was only using it as a kind of hac
|
| + if (event.type == ChangeType.REMOVE) { |
| + barback.removeSources([id]); |
| + } else { |
| + barback.updateSources([id]); |
| + } |
| + }); |
| } |
| log.message("Serving ${entrypoint.root.name} " |