loadGitDependencies function
Get all git dependencies from the local pubspec.yaml
Implementation
Iterable<GitDependencyReference> loadGitDependencies([
String location = 'pubspec.yaml',
]) {
final rawPubspec = File(location).readAsStringSync();
final ignores = <String, List<GdpLint>>{};
final lines = Queue<String>.from(rawPubspec.split('\n'));
while (lines.isNotEmpty) {
final line = lines.removeFirst();
// If this is the last line, break
if (lines.isEmpty) break;
if (line.trim().startsWith('# ignore:')) {
final ignored = line
.split(':')[1]
.split(',')
.map((e) => e.trim())
.map(GdpLint.fromCode)
.whereType<GdpLint>()
.toList();
final package = lines.removeFirst().trim().split(':').first;
ignores[package] = ignored;
}
}
final pubspec = loadYaml(rawPubspec);
final gitDependencies = {
..._filterGitDependencies('dependencies', pubspec['dependencies'], ignores),
..._filterGitDependencies(
'dev_dependencies',
pubspec['dev_dependencies'],
ignores,
),
..._filterGitDependencies(
'dependency_overrides',
pubspec['dependency_overrides'],
ignores,
),
}.values;
return gitDependencies;
}