Index: sdk/lib/_internal/pub/lib/src/pubspec.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/pubspec.dart b/sdk/lib/_internal/pub/lib/src/pubspec.dart |
index 883a77c961c8c7344b6a119b251b9364a09c53d4..862097031126d5142b2daa2849326bcc8059b61c 100644 |
--- a/sdk/lib/_internal/pub/lib/src/pubspec.dart |
+++ b/sdk/lib/_internal/pub/lib/src/pubspec.dart |
@@ -209,6 +209,39 @@ class Pubspec { |
} |
PubspecEnvironment _environment; |
+ /// The URL of the server that the package should default to being published |
+ /// to, "none" if the package should not be published, or `null` if it should |
+ /// be published to the default server. |
nweiz
2014/08/01 01:12:13
Document that if this returns a URL, it's guarante
Bob Nystrom
2014/08/04 21:16:43
Done.
|
+ String get publishTo { |
+ if (_parsedPublishTo) return _publishTo; |
+ |
+ var publishTo = fields['publishTo']; |
+ if (publishTo != null) { |
+ var span = fields.nodes['publishTo'].span; |
+ |
+ if (publishTo is! String) { |
+ _error ('"publishTo" field must be a string.', span); |
nweiz
2014/08/01 01:12:13
Nit: no space after _error.
Bob Nystrom
2014/08/04 21:16:43
Done.
|
+ } |
+ |
+ // It must be "none" or a valid URL. |
+ if (publishTo != "none") { |
+ _wrapFormatException('"publishTo" field', span, |
+ () => Uri.parse(publishTo)); |
+ } |
+ } |
+ |
+ _parsedPublishTo = true; |
+ _publishTo = publishTo; |
+ return _publishTo; |
+ } |
+ bool _parsedPublishTo = false; |
+ String _publishTo; |
+ |
+ /// Whether the package is private and cannot be published. |
+ /// |
+ /// This is specified in the pubspec by setting "publishTo" to "none". |
+ bool get isPrivate => publishTo == "none"; |
+ |
/// Whether or not the pubspec has no contents. |
bool get isEmpty => |
name == null && version == Version.none && dependencies.isEmpty; |
@@ -304,6 +337,7 @@ class Pubspec { |
_getError(() => this.devDependencies); |
_getError(() => this.transformers); |
_getError(() => this.environment); |
+ _getError(() => this.publishTo); |
return errors; |
} |