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

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

Issue 397843005: Lazily load the entrypoint. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
Index: sdk/lib/_internal/pub/lib/src/command.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command.dart b/sdk/lib/_internal/pub/lib/src/command.dart
index c37dc1cad361f2db69714010dec4d526c057a7f0..0b3e985bb2ba83de6dedacc646630903088e1367 100644
--- a/sdk/lib/_internal/pub/lib/src/command.dart
+++ b/sdk/lib/_internal/pub/lib/src/command.dart
@@ -109,7 +109,17 @@ abstract class PubCommand {
ArgResults get commandOptions => _commandOptions;
ArgResults _commandOptions;
- Entrypoint entrypoint;
+ /// Gets the [Entrypoint] package for the current working directory.
+ ///
+ /// This will load the pubspec and fail with an error if the current directory
+ /// is not a package.
+ Entrypoint get entrypoint {
+ // Lazy load it.
+ if (_entrypoint == null) _entrypoint = new Entrypoint(path.current, _cache);
+ return _entrypoint;
+ }
+
+ Entrypoint _entrypoint;
/// A one-line description of this command.
String get description;
@@ -130,12 +140,6 @@ abstract class PubCommand {
/// The URL for web documentation for this command.
String get docUrl => null;
- /// Whether or not this command requires [entrypoint] to be defined.
- ///
- /// If false, pub won't look for a pubspec and [entrypoint] will be null when
- /// the command runs. This only needs to be set in leaf commands.
- bool get requiresEntrypoint => true;
-
/// Whether or not this command takes arguments in addition to options.
///
/// If false, pub will exit with an error if arguments are provided. This
@@ -184,13 +188,6 @@ abstract class PubCommand {
_cache = new SystemCache.withSources(cacheDir, isOffline: isOffline);
_globals = new GlobalPackages(_cache);
- if (requiresEntrypoint) {
- // TODO(rnystrom): Will eventually need better logic to walk up
- // subdirectories until we hit one that looks package-like. For now,
- // just assume the cwd is it.
- entrypoint = new Entrypoint(path.current, cache);
- }
-
return syncFuture(onRun);
}

Powered by Google App Engine
This is Rietveld 408576698