OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'package:barback/barback.dart'; | 8 import 'package:barback/barback.dart'; |
9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
10 import 'package:watcher/watcher.dart'; | 10 import 'package:watcher/watcher.dart'; |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 | 602 |
603 /// Adds a file watcher for [dir] within [package], if the directory exists | 603 /// Adds a file watcher for [dir] within [package], if the directory exists |
604 /// and the package needs watching. | 604 /// and the package needs watching. |
605 Future<StreamSubscription<WatchEvent>> _watchDirectorySources( | 605 Future<StreamSubscription<WatchEvent>> _watchDirectorySources( |
606 Package package, String dir) { | 606 Package package, String dir) { |
607 // If this package comes from a cached source, its contents won't change so | 607 // If this package comes from a cached source, its contents won't change so |
608 // we don't need to monitor it. `packageId` will be null for the | 608 // we don't need to monitor it. `packageId` will be null for the |
609 // application package, since that's not locked. | 609 // application package, since that's not locked. |
610 var packageId = graph.lockFile.packages[package.name]; | 610 var packageId = graph.lockFile.packages[package.name]; |
611 if (packageId != null && | 611 if (packageId != null && |
612 graph.entrypoint.cache.sources[packageId.source] is CachedSource) { | 612 graph.entrypoint.cache.source(packageId.source) is CachedSource) { |
613 return new Future.value(); | 613 return new Future.value(); |
614 } | 614 } |
615 | 615 |
616 var subdirectory = package.path(dir); | 616 var subdirectory = package.path(dir); |
617 if (!dirExists(subdirectory)) return new Future.value(); | 617 if (!dirExists(subdirectory)) return new Future.value(); |
618 | 618 |
619 // TODO(nweiz): close this watcher when [barback] is closed. | 619 // TODO(nweiz): close this watcher when [barback] is closed. |
620 var watcher = _watcherType.create(subdirectory); | 620 var watcher = _watcherType.create(subdirectory); |
621 var subscription = watcher.events.listen((event) { | 621 var subscription = watcher.events.listen((event) { |
622 // Don't watch files symlinked into these directories. | 622 // Don't watch files symlinked into these directories. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 String toString() => "polling"; | 787 String toString() => "polling"; |
788 } | 788 } |
789 | 789 |
790 class _NoneWatcherType implements WatcherType { | 790 class _NoneWatcherType implements WatcherType { |
791 const _NoneWatcherType(); | 791 const _NoneWatcherType(); |
792 | 792 |
793 DirectoryWatcher create(String directory) => null; | 793 DirectoryWatcher create(String directory) => null; |
794 | 794 |
795 String toString() => "none"; | 795 String toString() => "none"; |
796 } | 796 } |
OLD | NEW |