Merge pull request #35 from joeconwaystk/master
Use PUB_HOSTED_URL if set
diff --git a/.travis.yml b/.travis.yml
index aaed16a..084f38e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,17 @@
language: dart
dart:
- dev
-script: ./tool/travis.sh
+ - stable
+
+install: ./tool/travis-setup.sh
+
+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/AUTHORS b/AUTHORS
index e8063a8..592b68c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -4,3 +4,5 @@
# Name/Organization <email address>
Google Inc.
+
+Joe Conway <joe.conway@stablekernel.com>
\ No newline at end of file
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..21f3640 100644
--- a/lib/pub_cache.dart
+++ b/lib/pub_cache.dart
@@ -106,11 +106,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'));
+ Directory dartlangDir = new Directory(
+ path.join(location.path, 'hosted', _getHostedPackageDirectoryName()));
if (dartlangDir.existsSync()) {
_packageRefs.addAll(dartlangDir
.listSync()
@@ -133,6 +133,12 @@
Directory _getSubDir(Directory dir, String name) =>
new Directory(path.join(dir.path, name));
+
+ String _getHostedPackageDirectoryName() {
+ final url = Uri.parse(
+ Platform.environment['PUB_HOSTED_URL'] ?? 'https://pub.dartlang.org');
+ return url.host;
+ }
}
/// A Dart application; a package with an entry-point, available via `pub global
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
diff --git a/tool/travis-setup.sh b/tool/travis-setup.sh
new file mode 100755
index 0000000..f594820
--- /dev/null
+++ b/tool/travis-setup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Fast fail the script on failures.
+set -e
+
+# Activate some packages for use while running tests.
+pub global activate tuneup
+pub global activate path 1.6.2
+pub global activate path
+pub global activate --source git https://github.com/dart-lang/test.git
+pub global activate --source path .
\ No newline at end of file
diff --git a/tool/travis.sh b/tool/travis.sh
index 62c4324..0374d89 100755
--- a/tool/travis.sh
+++ b/tool/travis.sh
@@ -4,16 +4,8 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-# Fast fail the script on failures.
set -e
-# Activate some packages for use while running tests.
-pub global activate tuneup
-pub global activate path 1.6.2
-pub global activate path
-pub global activate --source git https://github.com/dart-lang/test.git
-pub global activate --source path .
-
# Verify that the libraries are error free.
dartanalyzer --fatal-warnings .