anchor.diff:    }
   
     Future _fetchAllDeps(FetchMode mode) {
  -    Iterable<Future> futures = _allDeps.values.map((_Package package) =>
  -        _fetchPackage(package, mode).catchError((e) => _logger.warning(e)));
  +    List<Future> futures = [];
  +    _allDeps.values.forEach((_Package package) {
  +      futures.add(
  +          _fetchPackage(package, mode).catchError((e) => _logger.warning(e)));
  +    });
       return Future.wait(futures);
     }
   
  
positive.code:    */
    Future<_PrepareDirRes> _preparePackageDir(_Package package, FetchMode mode) {
      final completer = new Completer();
      _packagesDir.getDirectory(package.name).catchError((_) {
        _packagesDir.createDirectory(package.name, exclusive: true).catchError((e) {
          completer.completeError(
              "Couldn't create directory for package '${package.name}': $e");
        }).then((chrome.DirectoryEntry dir) {
          completer.complete(new _PrepareDirRes(dir, false));
        });
      }).then((chrome.DirectoryEntry dir) {
        // TODO(ussuri): issue #1694 (remove the 'if'; just complete with
        // _PrepareDirRes(dir, true)).
        if (mode == FetchMode.UPGRADE) {
          dir.removeRecursively().then((_) {
            completer.complete(new _PrepareDirRes(dir, true));
          });
        } else {
          completer.complete(new _PrepareDirRes(dir, true));
        }
      });
  
      return completer.future;
    }
  
    Future _clonePackage(_Package package, chrome.DirectoryEntry dir) {
  
negative.code:   }
  
    Future _fetchPackage(_Package package, FetchMode mode) {
      return _preparePackageDir(package, mode).catchError((e) {
        // TODO(ussuri): Is this needed?
        return new Future.error(e);
      }).then((_PrepareDirRes res) {
        if (!res.existed && mode == FetchMode.INSTALL) {
          // _preparePackageDir created the directory.
          return _clonePackage(package, res.entry);
        } else if (!res.existed && mode == FetchMode.UPGRADE) {
          // _preparePackageDir created the directory.
          // TODO(ussuri): Verify that installing missing packages is what
          // 'bower update' really does (maybe it just updates existing ones).
          return _clonePackage(package, res.entry);
        } else if (res.existed && mode == FetchMode.INSTALL) {
          // Skip fetching (don't even try to analyze the directory's contents).
          return new Future.value();
        } else if (res.existed && mode == FetchMode.UPGRADE) {
          // TODO(ussuri): #1694 - when fixed, switch to using 'git pull'.
          return _clonePackage(package, res.entry);
        } else {
          throw new StateError('Unhandled case');
        }
      });
    }
  