rewriteDependencies static method
void
rewriteDependencies(
- String targetPubspecPath,
- Map<String, dynamic> oldDeps
)
Implementation
static void rewriteDependencies(String targetPubspecPath, Map<String, dynamic> oldDeps) {
final file = File(targetPubspecPath);
if (!file.existsSync()) {
throw Exception('pubspec.yaml not found at $targetPubspecPath');
}
final content = file.readAsStringSync();
final editor = YamlEditor(content);
editor.update(['dependencies'], oldDeps['dependencies'] ?? {});
editor.update(['dev_dependencies'], oldDeps['dev_dependencies'] ?? {});
file.writeAsStringSync(editor.toString());
}