-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve workspace root and workPackage when invoking pub from any sub-directory #4186
Resolve workspace root and workPackage when invoking pub from any sub-directory #4186
Conversation
lib/src/entrypoint.dart
Outdated
withPubspecOverrides: true, | ||
); | ||
for (final package in root.transitiveWorkspace) { | ||
pubspecsMet.entries.first; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it is :)
); | ||
for (final package in root.transitiveWorkspace) { | ||
pubspecsMet.entries.first; | ||
if (identical(pubspecsMet.entries.first.value, package.pubspec)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to find the Package
object that has the first Pubspec
that we loaded. Such that we can refer it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you relying on the iteration order for .entries
-- that's seems a little surprising.
Maybe, make like a firstPubspecMet
variable that is nullable?
Is this because the root loads the packages? Ah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can rely on the insertion order of a map.
I don't really have any reservations here. It's probably, but perhaps a few documentation comments would help us review it :D |
); | ||
for (final package in root.transitiveWorkspace) { | ||
pubspecsMet.entries.first; | ||
if (identical(pubspecsMet.entries.first.value, package.pubspec)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you relying on the iteration order for .entries
-- that's seems a little surprising.
Maybe, make like a firstPubspecMet
variable that is nullable?
Is this because the root loads the packages? Ah.
lib/src/package.dart
Outdated
factory Package.load( | ||
String? name, | ||
String dir, | ||
SourceRegistry sources, { | ||
bool withPubspecOverrides = false, | ||
Map<String, Pubspec> alreadyLoadedPubspecs = const {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, how about passing a loadPubspec()
function?
Then you won't need to document the structure of the map, and the fact that things are cached is something you can hide altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Part of dart-lang/pub#4127 This link is referred in dart-lang/pub#4186 Later it should be updated to point at the actual documentation. For now it is pointing at the design doc.
Part of dart-lang/pub#4127 This link is referred in dart-lang/pub#4186 Later it should be updated to point at the actual documentation. For now it is pointing at the design doc.
Part of #4127