mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Use `Isolate.packageConfigSync! to locate the packageconfig of flutter tools (#150340)
This is a small refactor. Using `loadPackageConfigWithLogging` seems wrong. We should be able to assume that the flutter_tool package_config is in place. Warm-up for https://github.com/flutter/flutter/issues/150196
This commit is contained in:
parent
b2b0a751ff
commit
ffdeaa1995
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:isolate';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:package_config/package_config.dart';
|
||||
@ -10,6 +11,11 @@ import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
|
||||
/// Loads the package configuration of the current isolate.
|
||||
Future<PackageConfig> currentPackageConfig() async {
|
||||
return loadPackageConfigUri(Isolate.packageConfigSync!);
|
||||
}
|
||||
|
||||
/// Load the package configuration from [file] or throws a [ToolExit]
|
||||
/// if the operation would fail.
|
||||
///
|
||||
|
@ -1222,14 +1222,7 @@ void log(logging.LogRecord event) {
|
||||
|
||||
Future<Directory> _loadDwdsDirectory(
|
||||
FileSystem fileSystem, Logger logger) async {
|
||||
final String toolPackagePath =
|
||||
fileSystem.path.join(Cache.flutterRoot!, 'packages', 'flutter_tools');
|
||||
final String packageFilePath =
|
||||
fileSystem.path.join(toolPackagePath, '.dart_tool', 'package_config.json');
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
fileSystem.file(packageFilePath),
|
||||
logger: logger,
|
||||
);
|
||||
final PackageConfig packageConfig = await currentPackageConfig();
|
||||
return fileSystem.directory(packageConfig['dwds']!.packageUriRoot);
|
||||
}
|
||||
|
||||
|
@ -175,16 +175,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
}) async {
|
||||
final shelf.Server server = await serverFactory();
|
||||
if (testPackageUri == null) {
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
fileSystem.file(fileSystem.path.join(
|
||||
Cache.flutterRoot!,
|
||||
'packages',
|
||||
'flutter_tools',
|
||||
'.dart_tool',
|
||||
'package_config.json',
|
||||
)),
|
||||
logger: logger,
|
||||
);
|
||||
final PackageConfig packageConfig = await currentPackageConfig();
|
||||
testPackageUri = packageConfig['test']!.packageUriRoot;
|
||||
}
|
||||
final File testDartJs = fileSystem.file(fileSystem.path.join(
|
||||
|
Loading…
Reference in New Issue
Block a user