Normalize path before searching for package config (#165392)
If we don't normalize the `.absolute.path` will look like `/child/.` And `Directory('/child/.').parent` is `Directory('/child)`.
This commit is contained in:
parent
e6fbc63d37
commit
95843ca334
@ -24,8 +24,8 @@ Future<PackageConfig> currentPackageConfig() async {
|
||||
// TODO(sigurdm): Only call this once per run - and read in from BuildInfo.
|
||||
File? findPackageConfigFile(Directory dir) {
|
||||
final FileSystem fileSystem = dir.fileSystem;
|
||||
Directory candidateDir = fileSystem.directory(fileSystem.path.normalize(dir.absolute.path));
|
||||
|
||||
Directory candidateDir = fileSystem.directory(dir.path).absolute;
|
||||
while (true) {
|
||||
final File candidatePackageConfigFile = candidateDir
|
||||
.childDirectory('.dart_tool')
|
||||
|
@ -45,5 +45,14 @@ void main() {
|
||||
isNotNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('Works with a relative directory', () {
|
||||
final Directory child = fileSystem.currentDirectory.childDirectory('child');
|
||||
|
||||
child.createSync(recursive: true);
|
||||
fileSystem.file('.dart_tool/package_config.json').createSync(recursive: true);
|
||||
fileSystem.currentDirectory = child;
|
||||
expect(findPackageConfigFile(fileSystem.directory('.')), isNotNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user