@@ -7,8 +7,8 @@ import 'dart:convert';
77import 'dart:io' ;
88
99import 'package:path/path.dart' as path;
10- import 'package:pubspec_parse/pubspec_parse.dart' ;
1110import '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
176176List <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+ }
0 commit comments