Use PUB_HOSTED_URL if available
diff --git a/.travis.yml b/.travis.yml
index aaed16a..d1338bf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,15 @@
language: dart
dart:
- dev
-script: ./tool/travis.sh
+ - stable
+
+jobs:
+ include:
+ - stage: test
+ script: ./tool/travis.sh
+ env: PUB_HOSTED_URL=https://pub.flutter-io.cn
+ - stage: test
+ script: ./tool/travis.sh
branches:
only:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1d88d09..b840b96 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## 0.2.2
+
+- Uses PUB_HOSTED_URL for finding hosted packages
+
## 0.2.1
- Dart 2 dependency upgrades
diff --git a/lib/pub_cache.dart b/lib/pub_cache.dart
index 6979ae6..61520c6 100644
--- a/lib/pub_cache.dart
+++ b/lib/pub_cache.dart
@@ -34,6 +34,11 @@
List<Application> _applications;
List<PackageRef> _packageRefs;
+ String get _hostedPackageDirectoryName {
+ final url = Uri.parse(Platform.environment['PUB_HOSTED_URL'] ?? 'https://pub.dartlang.org');
+ return url.host;
+ }
+
/// Create a pubcache instance. [dir] defaults to the default platform pub
/// cache location.
PubCache([Directory dir])
@@ -106,11 +111,11 @@
.toList();
}
- // Scan hosted packages - just pub.dartlang.org for now.
+ // Scan hosted packages
_packageRefs = <PackageRef>[];
Directory dartlangDir =
- new Directory(path.join(location.path, 'hosted', 'pub.dartlang.org'));
+ new Directory(path.join(location.path, 'hosted', _hostedPackageDirectoryName));
if (dartlangDir.existsSync()) {
_packageRefs.addAll(dartlangDir
.listSync()
diff --git a/pubspec.yaml b/pubspec.yaml
index ca878a1..6ef7fab 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: pub_cache
-version: 0.2.1
+version: 0.2.2
description: A library to reflect on the local pub cache.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/pub_cache