Skip to content

Commit 14a9767

Browse files
liamappelbeDhruv-Maradiya
authored andcommitted
[coverage] Switch from package:pubspec_parse to package:yaml (dart-lang#2103)
1 parent b837c1e commit 14a9767

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

pkgs/coverage/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.14.1-wip
2+
3+
- Remove dependency on `package:pubspec_parse`.
4+
15
## 1.14.0
26

37
- Require Dart ^3.6.0

pkgs/coverage/lib/src/util.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import 'dart:convert';
77
import 'dart:io';
88

99
import 'package:path/path.dart' as path;
10-
import 'package:pubspec_parse/pubspec_parse.dart';
1110
import 'package:vm_service/vm_service.dart';
11+
import 'package:yaml/yaml.dart';
1212

1313
// TODO(cbracken) make generic
1414
/// Retries the specified function with the specified interval and returns
@@ -174,12 +174,16 @@ List<String> getAllWorkspaceNames(String packageRoot) =>
174174
_getAllWorkspaceNames(packageRoot, <String>[]);
175175

176176
List<String> _getAllWorkspaceNames(String packageRoot, List<String> results) {
177-
final pubspecPath = getPubspecPath(packageRoot);
178-
final yaml = File(pubspecPath).readAsStringSync();
179-
final pubspec = Pubspec.parse(yaml, sourceUrl: Uri.file(pubspecPath));
180-
results.add(pubspec.name);
181-
for (final workspace in pubspec.workspace ?? <String>[]) {
182-
_getAllWorkspaceNames(path.join(packageRoot, workspace), results);
177+
final pubspec = _loadPubspec(packageRoot);
178+
results.add(pubspec['name'] as String);
179+
for (final workspace in pubspec['workspace'] as YamlList? ?? []) {
180+
_getAllWorkspaceNames(path.join(packageRoot, workspace as String), results);
183181
}
184182
return results;
185183
}
184+
185+
YamlMap _loadPubspec(String packageRoot) {
186+
final pubspecPath = getPubspecPath(packageRoot);
187+
final yaml = File(pubspecPath).readAsStringSync();
188+
return loadYaml(yaml, sourceUrl: Uri.file(pubspecPath)) as YamlMap;
189+
}

pkgs/coverage/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: coverage
2-
version: 1.14.0
2+
version: 1.14.1-wip
33
description: Coverage data manipulation and formatting
44
repository: https://github.com/dart-lang/tools/tree/main/pkgs/coverage
55
issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Acoverage
@@ -15,10 +15,10 @@ dependencies:
1515
meta: ^1.0.2
1616
package_config: ^2.0.0
1717
path: ^1.8.0
18-
pubspec_parse: ^1.5.0
1918
source_maps: ^0.10.10
2019
stack_trace: ^1.10.0
2120
vm_service: '>=12.0.0 <16.0.0'
21+
yaml: ^3.1.3
2222

2323
dev_dependencies:
2424
benchmark_harness: ^2.2.0

0 commit comments

Comments
 (0)