Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Unified Diff: sdk/lib/_internal/pub/lib/src/command/serve.dart

Issue 22986002: Add file watching to pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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} "

Powered by Google App Engine
This is Rietveld 408576698