watchTargetDirectory method

void watchTargetDirectory(
  1. String wd
)

Implementation

void watchTargetDirectory(String wd) {
  _parentWatcher?.cancel();
  _parentWatcher = null;

  if (VPaths.hasParent(wd)) {
    _parentWatcher =
        watchDirectory(VPaths.parentOf(wd)).listen((event) async {
      await checkWorkingDirectory();
      update();
    }, onDone: () {
      verbose("PARENT WATCH ENDED");
      checkWorkingDirectory();
    }, onError: (e, es) {
      error("PARENT WATCH ERROR $e $es");
      checkWorkingDirectory();
    });
  }

  _watcher?.cancel();
  _watcher = null;
  _watcher = watchDirectory(wd).listen((event) async {
    update();
  }, onDone: () {
    verbose("WATCH ENDED");
  }, onError: (e, es) {
    error("WATCH ERROR $e $es");
  });
}