Remove the dependency on pubspec_parse (#2580)
Fixes #2579
diff --git a/pkgs/test_core/lib/src/util/package_config.dart b/pkgs/test_core/lib/src/util/package_config.dart
index 042cb31..bab1eaf 100644
--- a/pkgs/test_core/lib/src/util/package_config.dart
+++ b/pkgs/test_core/lib/src/util/package_config.dart
@@ -7,7 +7,7 @@
import 'package:package_config/package_config.dart';
import 'package:path/path.dart' as p;
-import 'package:pubspec_parse/pubspec_parse.dart';
+import 'package:yaml/yaml.dart';
/// The [PackageConfig] parsed from the current isolates package config file.
final Future<PackageConfig> currentPackageConfig = () async {
@@ -56,10 +56,20 @@
final pubspecFile = File(pubspecUri.toFilePath());
if (pubspecFile.existsSync()) {
final yaml = pubspecFile.readAsStringSync();
- final pubspec = Pubspec.parse(yaml, sourceUrl: pubspecUri);
- results.add(pubspec.name);
- for (final package in pubspec.workspace ?? const <String>[]) {
- _allWorkspaceNames(packageRoot.resolve('$package/'), results);
+ final pubspec = loadYaml(yaml, sourceUrl: pubspecUri);
+ final name = pubspec['name'];
+ if (name is String) {
+ results.add(name);
+ } else {
+ throw FormatException(
+ "Pubspec doesn't contain a valid name field: $pubspecUri",
+ );
+ }
+ final workspace = pubspec['workspace'];
+ if (workspace is Iterable) {
+ for (final package in workspace) {
+ _allWorkspaceNames(packageRoot.resolve('$package/'), results);
+ }
}
}
return results;
diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml
index c45a920..e90d36f 100644
--- a/pkgs/test_core/pubspec.yaml
+++ b/pkgs/test_core/pubspec.yaml
@@ -22,7 +22,6 @@
package_config: ^2.0.0
path: ^1.8.0
pool: ^1.5.0
- pubspec_parse: ^1.5.0
source_map_stack_trace: ^2.1.0
source_maps: ^0.10.10
source_span: ^1.8.0