Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: sdk/lib/_internal/pub/lib/src/hosted_source.dart

Issue 15444003: Use args' command support for pub commands. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Initialize command args in constructor. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command_uploader.dart ('k') | sdk/lib/_internal/pub/test/pub_cache_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/hosted_source.dart
diff --git a/sdk/lib/_internal/pub/lib/src/hosted_source.dart b/sdk/lib/_internal/pub/lib/src/hosted_source.dart
index 62503fe1274f6b2d3a1c7f1c28837f512a96310c..a793f656ee065d688fae8efa7c46d7efe1a50f90 100644
--- a/sdk/lib/_internal/pub/lib/src/hosted_source.dart
+++ b/sdk/lib/_internal/pub/lib/src/hosted_source.dart
@@ -25,6 +25,9 @@ import 'version.dart';
/// A package source that installs packages from a package hosting site that
/// uses the same API as pub.dartlang.org.
class HostedSource extends Source {
+ /// The URL of the default package repository.
+ static const DEFAULT_URL = "https://pub.dartlang.org";
+
final name = "hosted";
final shouldCache = true;
@@ -121,7 +124,7 @@ class HostedSource extends Source {
}
List<Package> getCachedPackages([String url]) {
- if (url == null) url = _defaultUrl;
+ if (url == null) url = DEFAULT_URL;
var cacheDir = path.join(systemCacheRoot,
_getSourceDirectory(url));
@@ -199,9 +202,6 @@ class OfflineHostedSource extends HostedSource {
}
}
-/// The URL of the default package repository.
-final _defaultUrl = "https://pub.dartlang.org";
-
String _getSourceDirectory(String url) {
url = url.replaceAll(new RegExp(r"^https?://"), "");
return replace(url, new RegExp(r'[<>:"\\/|?*%]'),
@@ -236,7 +236,7 @@ Uri _makeVersionUrl(PackageId id,
/// this throws a descriptive FormatException.
Pair<String, String> _parseDescription(description) {
if (description is String) {
- return new Pair<String, String>(description, _defaultUrl);
+ return new Pair<String, String>(description, HostedSource.DEFAULT_URL);
}
if (description is! Map) {
@@ -254,6 +254,8 @@ Pair<String, String> _parseDescription(description) {
throw new FormatException("The 'name' key must have a string value.");
}
- var url = description.containsKey("url") ? description["url"] : _defaultUrl;
+ var url = description["url"];
+ if (url == null) url = HostedSource.DEFAULT_URL;
+
return new Pair<String, String>(name, url);
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command_uploader.dart ('k') | sdk/lib/_internal/pub/test/pub_cache_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698