-
Notifications
You must be signed in to change notification settings - Fork 23
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
extension_discovery: add findPackageConfig()
#590
extension_discovery: add findPackageConfig()
#590
Conversation
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
License Headers ✔️
All source files should start with a license header. Package publish validation ✔️
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
/// | ||
/// Alternatively a [packageRootDir] can be provided. That is a file uri the the | ||
/// directory containing the `pubspec.yaml` of [targetPackage]. In that case the | ||
/// package_config will be searched by looking in all parent directories. |
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.
/// package_config will be searched by looking in all parent directories. | |
/// [packageConfig] will be searched by looking in all parent directories. |
findExtensions()
with packageDir
findPackageConfig()
1c03d97
to
b311c55
Compare
} | ||
while (true) { | ||
final packageConfigCandidate = | ||
packageDir.resolve('.dart_tool/package_config.json'); |
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.
this logic is assuming /
is the separator, which won't be true for Windows. Should we be using the path package instead to support Windows paths?
CC @DanTup since you have resolved many windows path issues in the past.
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.
Good point - I think we are good here though.
These are file urls not file paths. Urls always use /
as a separator.
Eg. this program:
import 'dart:io';
void main(List<String> args) {
print(Uri.file('c:\\abc\\def\\', windows: true));
}
Prints:
file:///c:/abc/def/
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.
Yep, this looks reasonable to me.
The things that usually cause issues are reading .path
from a File URI, assuming it's correct for Windows (it's not, but it is correct for non-Windows), and going to/from Windows paths when running in the browser (because Dart always treats web as non-Windows even if the file:///
URI is a Windows path).
I note the code below is doing File.fromUri()
which will call toFilePath()
but since it's calling existsSync()
I assume that this code only runs on the host machine (not in a browser) and therefore I don't think any of those gotchas apply here.
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 assume that this code only runs on the host machine (not in a browser)
Yes, this is running on the host.
This will make it easier to use from a pub workspace.