getDependencies function

Future<List<MapEntry<String, Dependency>>> getDependencies(
  1. Directory projectDir
)

Get the dependencies from the pubspec.yaml file

Implementation

Future<List<MapEntry<String, Dependency>>> getDependencies(
  Directory projectDir,
) async {
  if (!pubspecExists(projectDir)) {
    return [];
  }

  Pubspec pubspecYaml = getPubspecYaml(projectDir);

  // Iterate all dependencies
  List<MapEntry<String, Dependency>> allDeps = [
    ...pubspecYaml.dependencies.entries,
    ...pubspecYaml.devDependencies.entries,
  ];
  return allDeps;
}