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
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'dart:isolate';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:package_config/package_config.dart';
|
import 'package:package_config/package_config.dart';
|
||||||
@ -10,6 +11,11 @@ import '../base/common.dart';
|
|||||||
import '../base/file_system.dart';
|
import '../base/file_system.dart';
|
||||||
import '../base/logger.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]
|
/// Load the package configuration from [file] or throws a [ToolExit]
|
||||||
/// if the operation would fail.
|
/// if the operation would fail.
|
||||||
///
|
///
|
||||||
|
@ -1222,14 +1222,7 @@ void log(logging.LogRecord event) {
|
|||||||
|
|
||||||
Future<Directory> _loadDwdsDirectory(
|
Future<Directory> _loadDwdsDirectory(
|
||||||
FileSystem fileSystem, Logger logger) async {
|
FileSystem fileSystem, Logger logger) async {
|
||||||
final String toolPackagePath =
|
final PackageConfig packageConfig = await currentPackageConfig();
|
||||||
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,
|
|
||||||
);
|
|
||||||
return fileSystem.directory(packageConfig['dwds']!.packageUriRoot);
|
return fileSystem.directory(packageConfig['dwds']!.packageUriRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,16 +175,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
|||||||
}) async {
|
}) async {
|
||||||
final shelf.Server server = await serverFactory();
|
final shelf.Server server = await serverFactory();
|
||||||
if (testPackageUri == null) {
|
if (testPackageUri == null) {
|
||||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
final PackageConfig packageConfig = await currentPackageConfig();
|
||||||
fileSystem.file(fileSystem.path.join(
|
|
||||||
Cache.flutterRoot!,
|
|
||||||
'packages',
|
|
||||||
'flutter_tools',
|
|
||||||
'.dart_tool',
|
|
||||||
'package_config.json',
|
|
||||||
)),
|
|
||||||
logger: logger,
|
|
||||||
);
|
|
||||||
testPackageUri = packageConfig['test']!.packageUriRoot;
|
testPackageUri = packageConfig['test']!.packageUriRoot;
|
||||||
}
|
}
|
||||||
final File testDartJs = fileSystem.file(fileSystem.path.join(
|
final File testDartJs = fileSystem.file(fileSystem.path.join(
|
||||||
|
Loading…
Reference in New Issue
Block a user